Kotlin / kotlinx.serialization

Kotlin multiplatform / multi-format serialization
Apache License 2.0
5.37k stars 620 forks source link

Didn't find class "kotlinx.serialization.json.Json" on path: DexPathList #2736

Open ravadisagarrao opened 3 months ago

ravadisagarrao commented 3 months ago

Able to compile code and generate .apk file and Below is the error we are getting during runtime.

07-02 13:57:49.245 19976 20076 E AndroidRuntime: FATAL EXCEPTION: pool-2-thread-5 07-02 13:57:49.245 19976 20076 E AndroidRuntime: Process: com.xyz.xyz.qa, PID: 19976 07-02 13:57:49.245 19976 20076 E AndroidRuntime: java.lang.NoClassDefFoundError: Failed resolution of: Lkotlinx/serialization/json/Json; 07-02 13:57:49.245 19976 20076 E AndroidRuntime: at ....... ..... 07-02 13:57:49.245 19976 20076 E AndroidRuntime: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) 07-02 13:57:49.245 19976 20076 E AndroidRuntime: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644) 07-02 13:57:49.245 19976 20076 E AndroidRuntime: at java.lang.Thread.run(Thread.java:1012) 07-02 13:57:49.245 19976 20076 E AndroidRuntime: Caused by: java.lang.ClassNotFoundException: Didn't find class "kotlinx.serialization.json.Json" on path: DexPathList[[zip file "/data/app/N6alC4MfPGo0PSOzCyFhTQ==/com.xyz.xyz.qa-kpgx5B81J2Pl9J1wikvpjg==/base.apk"],nativeLibraryDirectories=[/data/app/N6alC4MfPGo0PSOzCyFhTQ==/com.xyz.xyz.qa-kpgx5B81J2Pl9J1wikvpjg==/lib/arm64, /data/app/~~N6alC4MfPGo0PSOzCyFhTQ==/com.xyz.xyz.qa-kpgx5B81J2Pl9J1wikvpjg==/base.apk!/lib/arm64-v8a, /system/lib64, /system_ext/lib64]] 07-02 13:57:49.245 19976 20076 E AndroidRuntime: at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:259) 07-02 13:57:49.245 19976 20076 E AndroidRuntime: at java.lang.ClassLoader.loadClass(ClassLoader.java:379) 07-02 13:57:49.245 19976 20076 E AndroidRuntime: at java.lang.ClassLoader.loadClass(ClassLoader.java:312) 07-02 13:57:49.245 19976 20076 E AndroidRuntime: ... 11 more

  1. Tried adding below entries in build.gradle.

**plugins { id 'org.jetbrains.kotlin.jvm' version '2.0.0' id 'org.jetbrains.kotlin.plugin.serialization' version '2.0.0' } repositories { mavenCentral() }

implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.1"**

  1. And one more thing what i observed is kotlinx-serialization-json is not getting downloaded to local .gradle folder.

  2. Also, in the generated .apk file I see kotlinx-serialization-json reference but still not able to find during runtime. FYI, please find screen attached. image

Environment

Any inputs appreciated.

sandwwraith commented 3 months ago

I'm not familiar with Cordova, so maybe it requires some additional setup. I can recommend you check if the issue is the same across different variants (debug and release). Maybe your minifying rules are too strict? Also, check in tests: if regular (non-device) tests do not have this problem, this also indicates problem with application packaging.