https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
l

louiscad

03/07/2019, 12:51 AM
Hi, does anyone know how to tell the Android Gradle Plugin to use content and dependencies of the
androidMain
sourceSet from Kotlin multiplatform plugin in an
androidTest
sourceSet (instrumented test)? My
build.gradle.kts
includes the following:
Copy code
android {
    setDefaults()
    sourceSets.getByName("androidTest").java.srcDir("src/androidInstrumentedTest/kotlin") // I put my instrumented tests here.
}
kotlin {
    android()
    sourceSets {
        getByName("androidMain").dependencies {
            // Some dependencies here
        }
    }
}
dependencies {
    androidTestImplementation(Libs.kotlin.testJunit)
    androidTestImplementation(Libs.androidX.test.coreKtx)
    androidTestImplementation(Libs.androidX.test.ext.junit)
    androidTestImplementation(Libs.androidX.test.runner)
    androidTestImplementation(Libs.kotlinX.coroutines.android)
}
The problem I encounter is that it compiles, but when an instrumented test is run, there's
NoClassDefFoundError
on anything defined in
androidMain
(be it source or dependency). Note that the IDE shows no warning and allows me to use the dependencies from
androidInstrumentedTest
, but it fails at runtime.
g

gildor

03/07/2019, 1:59 AM
n

nestserau

03/07/2019, 1:39 PM
Search through this channel for a workaround, was discussed a couple of days ago.
4 Views