When I follow the directions for setting up Compos...
# multiplatform
r
When I follow the directions for setting up Compose Multiplatform UI tests using the current KMP plugin-generated template app (which uses kotlin 2.2.20), I get a Kotlin gradle DSL errors about the kotlin > androidTarget > dependencies block and its contents. (See https://www.jetbrains.com/help/kotlin-multiplatform-dev/compose-test.html#create-the-test-source-set-and-add-the-testing-library-to-dependencies, step #3, sub-step #3, which adds the code below.)
kotlin {
// ...
androidTarget {
// ...
dependencies {
androidTestImplementation("androidx.compose.uiui test junit4 android1.8.2")
debugImplementation("androidx.compose.uiui test manifest1.8.2")
}
}
}
The first compilation error is "'fun dependencies(configure: KotlinDependencies.() -> Unit): Unit' cannot be called in this context with an implicit receiver. Use an explicit receiver if necessary." Replacing
dependencies
with
this@kotlin.dependencies
gets past that problem, but then
androidTestImplementation
and
debugImplementation
are both flagged as "Unresolved reference" errors. Is anyone else seeing these issues? Any workarounds? Thanks!
p
Hi Robert, thanks for reporting this. I'll share the feedback with the JetBrains Tech Writers.
I think quite possibly we've updated the app, but not the tutorial fully. Sorry about that, we'll try to fix ASAP
❤️ 1
e
Hi Robert! Thank you for your feedback Seems we made a small mistake in the doc and instead of this
Add the required dependencies for `androidTarget`:
```kotlin {
// ...
androidTarget {
// ...
dependencies {
androidTestImplementation("androidx.compose.uiui test junit4 android1.9.0")
debugImplementation("androidx.compose.uiui test manifest1.9.0")
}
}
}```
It should be that way
Add the required dependencies in the root `build.gradle.kts`:
```dependencies {
// ...
androidTestImplementation("androidx.compose.uiui test junit4 android1.9.0")
debugImplementation("androidx.compose.uiui test manifest1.9.0")
}```
Could you please try this solution?
thank you color 1
r
@Ekaterina Zaitseva That seems to have done the trick. Thanks! One note: when you say "in the root `build.gradle.kts`", I think of the file in the project root folder which holds the
plugins { ... }
declaration, but no
dependencies { ... }
. Instead, I added those lines to what I'd call the "root
dependencies
in the
composeApp
build.gradle.kts
file" (along with
debugImplementation(compose.uiTooling)
) and it worked. I hope that helps.
💯 1
e
Great news! 🎉 Thank you very much for the comment, you're right, that is probably clearer