Thread
#multiplatform
    Tobi

    Tobi

    3 years ago
    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.kotlinx:kotlinx-coroutines-core-common:$coroutines_version” implementation “org.jetbrains.kotlinx:kotlinx-serialization-runtime-common:$serialization_version” implementation “io.ktor:ktor-client-core:$ktor_version” implementation “io.ktor:ktor-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.kotlinx:kotlinx-coroutines-core:$coroutines_version” implementation “org.jetbrains.kotlinx:kotlinx-serialization-runtime:$serialization_version” implementation “io.ktor:ktor-client-core-jvm:$ktor_version” implementation “io.ktor:ktor-client-json-jvm:$ktor_version” implementation “io.ktor:ktor-client-okhttp:$ktor_version” } } androidTest { dependencies { implementation ‘org.jetbrains.kotlin:kotlin-test’ implementation ‘org.jetbrains.kotlin:kotlin-test-junit’ api “io.ktor:ktor-client-mock-jvm:$ktor_version” implementation “com.nhaarman.mockitokotlin2:mockito-kotlin:2.1.0” implementation “org.mockito:mockito-inline:2.22.0" } } iOSMain { dependencies { implementation “org.jetbrains.kotlinx:kotlinx-coroutines-core-native:$coroutines_version” implementation “org.jetbrains.kotlinx:kotlinx-serialization-runtime-native:$serialization_version” implementation “io.ktor:ktor-client-ios:$ktor_version” implementation “io.ktor:ktor-client-core-native:$ktor_version” implementation “io.ktor:ktor-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

    3 years ago
    Did you update kotlinx serialization too? It is required because to binary compatibility issues.
    Tobi

    Tobi

    3 years ago
    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 🙏