MobileNativeFoundation/Store

java.lang.NoClassDefFoundError: Failed resolution of: Lkotlinx/atomicfu/AtomicFU

SridharShanmugam opened this issue ยท 11 comments

When migrating from Store4 to Store5, the below-mentioned crash happened in the Android platform.

java.lang.NoClassDefFoundError: Failed resolution of: Lkotlinx/atomicfu/AtomicFU;
        at org.mobilenativefoundation.store.store5.impl.SourceOfTruthWithBarrier.<init>(SourceOfTruthWithBarrier.kt:57)
        at org.mobilenativefoundation.store.store5.impl.RealStore.<init>(RealStore.kt:56)
        at org.mobilenativefoundation.store.store5.impl.RealStoreBuilder.build(RealStoreBuilder.kt:38)
Caused by: java.lang.ClassNotFoundException: Didn't find class "kotlinx.atomicfu.AtomicFU" on path

In the latest Store5, since the Kotlin version 1.7.21 is used, I have updated the Compose Compiler Version to 1.4.0-alpha02. But in the AtomicFU, they have mentioned turning on IR transformation by setting the below-mentioned properties in the gradle.properties file for Kotlin version >= 1.7.20.

kotlinx.atomicfu.enableJvmIrTransformation=true // for JVM IR transformation
kotlinx.atomicfu.enableJsIrTransformation=true // for JS IR transformation

But in the Store5 gradle.properties file, it was configured as mentioned below for the AtomicFU version 0.18.5.

kotlinx.atomicfu.enableJvmIrTransformation=false
kotlinx.atomicfu.enableJsIrTransformation=false
kotlin.js.compiler=ir

I'm not sure whether this might be the reason for the above-mentioned crash in the Android platform.

Hello! First off just a warning store5 is not stable yet. You are free to play with it but we do not recommend prod usage yet.

As for the error. Could you try adding this dependency to modules uses store https://search.maven.org/artifact/org.jetbrains.kotlinx/atomicfu/0.18.5/pom

I have tried adding the AtomicFU dependency in the Android project and checked with Kotlin versions 1.7.20 (used in the AtomicFU) and 1.7.21, but still, the same crash occurred in the Android.

hmm strange, I have. KMP project where I was able to successfully add Store5 and compile the android app. https://github.com/AndroidDev-social/DodoForMastodon/blob/main/data/repository/build.gradle.kts#L35

I'll try to make an android specific sample. If you have something you can push for me to see not working that would help as well. I probably won't be able to get to this until after the holidays. Thank you for the report

Hey all

@digitalbuddha Will get up fix tn
@SridharShanmugam Let us know if you continue to hit this

@SridharShanmugam - Still hitting this unfortunately. Seems to be known Atomic FU issue. See Kotlin/kotlinx-atomicfu#145. Will investigate https://github.com/touchlab/Stately as alternative. For now please add the dependency explicitly

Updated README

Thank you for the updated solution @matt-ramotar . I think you can mention adding the AtomicFU dependency using implementation instead of api in the Android section on Including Store In Your Project in the README file.

How to reproduce the issue @matt-ramotar ? I tried howl-so/xplat@4f7b3c4 , but no (store) issue.

Hey! Sorry to be slow. After cloning the repo and checking out that commit, the app should crash at runtime

Hmm, yes the app crashes but with a different exception (not inited lateinit). I worked around those issues so the app starts at least and request data. But no atomicFu exception .

Just wanna note , we're using store4-kmp in our team published on private maven without any problems. I don't even provide atomicFu as "api" just as "implementation". The only difference i can spot so far is that i'm not using the atmicFu plugin as that's not needed if provided via "implementation"