Just a heads up, this weekend I tried starting a multiplatform project using kotlinx.serialization library and just couldn't figure out how to get it to serialize a response. I kept having the error I show below. I suspect it has something to do with the versions of the libraries I was using. I know that if you're using
Kotlin plugin version 1.3.70
you
MUST use
kotlinx.serialization version 0.20.0
because it's
NOT backwards compatible. Spent a whole day stuck, finally ended up reverting back to
Kotlin plugin 1.3.61
and
kotlinx.serialization 0.14.0
and it finally worked. Also used
ktor 1.3.1
. Just wondering if anybody has tried using the
kotlinx.serialization
library with
Kotlin 1.3.70
successfully?
Here's a GitHub gist:
https://gist.github.com/lamvann/d441b2529d4f3b164edc5947401a1e4f
E/AndroidRuntime: FATAL EXCEPTION: main
Process: org.jetbrains.kotlin.mpp_app_android, PID: 28267
java.lang.NoSuchFieldError: No field Companion of type Lkotlinx/serialization/json/Json$Companion; in class Lkotlinx/serialization/json/Json; or its superclasses (declaration of 'kotlinx.serialization.json.Json' appears in /data/app/org.jetbrains.kotlin.mpp_app_android-InBSbzMi00a168C538jy0g==/base.apk)
at io.ktor.client.features.json.serializer.KotlinxSerializer.<init>(KotlinxSerializer.kt:22)