https://kotlinlang.org logo
#intellij
Title
# intellij
m

Mustafa Ozhan

10/22/2023, 5:08 PM
Navigation between gradle kts files and toml files are broken if I use scope function like below
Copy code
libs.apply {
        android.apply {
            implementation(composeActivity)
            implementation(composeNavigation)
            implementation(constraintLayout)
            implementation(navigation)
            implementation(koinAndroid)
            implementation(koinCompose)
            implementation(lifecycleRuntime)
            implementation(splashScreen)
        }
}
but works if I use
Copy code
implementation(libs.android.composeActivity)
            implementation(libs.android.composeNavigation)
            implementation(libs.android.constraintLayout)
            implementation(libs.android.navigation)
            implementation(libs.android.koinAndroid)
            implementation(libs.android.koinCompose)
            implementation(libs.android.lifecycleRuntime)
            implementation(libs.android.splashScreen)
is there any way to fix this issue ? It is quite helpful in KMP projects. Also dependencies seems as not used when I use scope functions
k

Klitos Kyriacou

10/23/2023, 8:30 AM
In your second code snippet,
Copy code
dependencies {
            implementation(libs.android.composeActivity)
}
calls
DependencyHandler.implementation(...)
and does the right thing. But in your first code snippet, considering what
apply
actually does:
Copy code
libs.apply {
        android.apply {
            implementation(composeActivity)
        }
}
is equivalent to calling
libs.android.implementation(composeActivity)
which is not the same thing.
m

Mustafa Ozhan

10/23/2023, 9:59 AM
in the second one it also calls the
Copy code
implementation(libs.android.composeActivity)
since we have the scope from
libs
and
android
, also
libs.android.implementation(composeActivity)
would give a compiler time error which doesn’t happen
k

Klitos Kyriacou

10/23/2023, 10:11 AM
You're right
2 Views