https://kotlinlang.org logo
t

Tobi

02/11/2019, 4:25 PM
Hey folks, after upgrading my multiplatform project to kotlin 1.3.20 and ktor 1.1.2 I am running into this exception when running my tests under common/androidTest. The problem just occurs when running the tests.
These are my dependencies: kotlin { targets { fromPreset(presets.android, ‘android’) // Change to
presets.iosArm64
to deploy the app to iPhone fromPreset(presets.iosX64, ‘iOS’) { compilations.main.outputKinds(‘FRAMEWORK’) } } sourceSets { commonMain { dependencies { implementation ‘org.jetbrains.kotlin:kotlin-stdlib-common’ implementation “org.jetbrains.kotlinxkotlinx coroutines core common$coroutines_version” implementation “org.jetbrains.kotlinxkotlinx serialization runtime common$serialization_version” implementation “io.ktorktor client core$ktor_version” implementation “io.ktorktor client json$ktor_version” } } commonTest { dependencies { implementation ‘org.jetbrains.kotlin:kotlin-test-common’ implementation ‘org.jetbrains.kotlin:kotlin-test-annotations-common’ } } androidMain { dependencies { implementation ‘org.jetbrains.kotlin:kotlin-stdlib-jdk8’ implementation “org.jetbrains.kotlinxkotlinx coroutines core$coroutines_version” implementation “org.jetbrains.kotlinxkotlinx serialization runtime$serialization_version” implementation “io.ktorktor client core jvm$ktor_version” implementation “io.ktorktor client json jvm$ktor_version” implementation “io.ktorktor client okhttp$ktor_version” } } androidTest { dependencies { implementation ‘org.jetbrains.kotlin:kotlin-test’ implementation ‘org.jetbrains.kotlin:kotlin-test-junit’ api “io.ktorktor client mock jvm$ktor_version” implementation “com.nhaarman.mockitokotlin2mockito kotlin2.1.0” implementation “org.mockitomockito inline2.22.0" } } iOSMain { dependencies { implementation “org.jetbrains.kotlinxkotlinx coroutines core native$coroutines_version” implementation “org.jetbrains.kotlinxkotlinx serialization runtime native$serialization_version” implementation “io.ktorktor client ios$ktor_version” implementation “io.ktorktor client core native$ktor_version” implementation “io.ktorktor client json native$ktor_version” } } }
For some reason
io.ktor.client.features.json.JsonFeature
cannot be resolved which should be included in
ktor-client-json
s

Sabrina Namur

02/12/2019, 6:28 AM
Did you update kotlinx serialization too? It is required because to binary compatibility issues.
t

Tobi

02/12/2019, 8:10 AM
I am using
0.10.0
for kotlinx serialization and besides the test everything works fine. ext.kotlin_version = ‘1.3.20’ ext.ktor_version = ‘1.1.2’ ext.serialization_version = ‘0.10.0’ ext.coroutines_version = ‘1.1.1’
I digged a bit deeper into this and realized I can reproduce it also just with
kotlinx/serialization/json/Json
. Furthermore I isolated the issue into this example repository: https://github.com/tobiasheine/Kotlin-Multiplatform-java.lang.NoClassDefFoundError just run
./gradlew :common:test
to reproduce the
java.lang.NoClassDefFoundError
. Any help would be much appreciated 🙏
2 Views