Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
SridharShanmugam opened this issue Dec 23, 2022 · 11 comments · Fixed by #505
Open
Labels
bug Something isn't working

Comments

@SridharShanmugam
Copy link

SridharShanmugam commented Dec 23, 2022

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.

@SridharShanmugam SridharShanmugam added the bug Something isn't working label Dec 23, 2022
@digitalbuddha
Copy link
Contributor

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

@SridharShanmugam
Copy link
Author

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.

@digitalbuddha
Copy link
Contributor

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

@matt-ramotar
Copy link
Collaborator

Hey all

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

@matt-ramotar matt-ramotar linked a pull request Dec 29, 2022 that will close this issue
@matt-ramotar
Copy link
Collaborator

@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

@matt-ramotar matt-ramotar reopened this Dec 30, 2022
@matt-ramotar
Copy link
Collaborator

Updated README

@SridharShanmugam
Copy link
Author

SridharShanmugam commented Jan 2, 2023

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.

@aclassen
Copy link
Contributor

aclassen commented Jan 7, 2023

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

@matt-ramotar
Copy link
Collaborator

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

@aclassen
Copy link
Contributor

aclassen commented Jan 13, 2023

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 .

@aclassen
Copy link
Contributor

aclassen commented Jan 16, 2023

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"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants