I have a complex project where version for
org.jetbrains.kotlinx:kotlinx-coroutines-android
is forced to 1.6.4.
I have used Jetpack composables for my UI screens. I want to write Instrumented Tests for integration testng.
The compose version applied to the project is 1.7.0
which uses a class that is present only in org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3
Hence, my compilation fails.
So the only solution for me is that I use compose 1.5.3 version for testing my composable UI, basically for the following dependencies
devImplementation("androidx.compose.ui:ui-test-manifest:1.5.3")
androidTestImplementation("androidx.compose.ui:ui-test-junit4:1.5.3")
Now I encounter the issue of duplicate classes because there are common classes in androidx.compose.ui:ui-test-junit4:1.5.3
and androidx.compose.ui:ui-test-android:1.7.0
.
I tried to exclude some dependencied which I found from my dependency graph but it still gives the same duplicate class issue.
devImplementation("androidx.compose.ui:ui-test-manifest:1.5.3") {
exclude group: "androidx.compose.ui", module: "ui"
exclude group: "androidx.compose.ui", module: "ui-graphics"
exclude group: "androidx.compose.ui", module: "ui-text"
exclude group: "androidx.compose.ui", module: "ui-unit"
exclude group: "androidx.compose.ui", module: "ui-tooling"
exclude group: "androidx.compose.ui", module: "ui-tooling-preview"
exclude group: "androidx.compose.ui", module: "ui-tooling-data"
}
androidTestImplementation("androidx.compose.ui:ui-test-junit4:1.5.3") {
exclude group: "androidx.compose.ui", module: "ui"
exclude group: "androidx.compose.ui", module: "ui-graphics"
exclude group: "androidx.compose.ui", module: "ui-text"
exclude group: "androidx.compose.ui", module: "ui-unit"
exclude group: "androidx.compose.ui", module: "ui-tooling"
exclude group: "androidx.compose.ui", module: "ui-tooling-preview"
exclude group: "androidx.compose.ui", module: "ui-tooling-data"
}
How can I resolve the duplicate classes issue in this case?
I was able to acheive this by forcing the version of following dependency.
resolutionStrategy.force "androidx.compose.ui:ui-test-android:1.5.3"