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 when using version 0.21.0 of AtomicFU #519

Closed
francismariano opened this issue Jul 4, 2023 · 1 comment · Fixed by #520
Closed

java.lang.NoClassDefFoundError when using version 0.21.0 of AtomicFU #519

francismariano opened this issue Jul 4, 2023 · 1 comment · Fixed by #520
Assignees

Comments

@francismariano
Copy link
Contributor

Hello, I have problem with the version 0.21.0 of AtomicFU, please see the log with the error.

java.lang.NoClassDefFoundError: Failed resolution of: Lkotlinx/atomicfu/AtomicFU;
        at com.juul.kable.BluetoothDeviceAndroidPeripheral.<init>(BluetoothDeviceAndroidPeripheral.kt:112)
        at com.juul.kable.PeripheralKt.peripheral(Peripheral.kt:30)
        at com.juul.kable.PeripheralKt.peripheral(Peripheral.kt:21)
        at com.juul.kable.PeripheralKt.peripheral$default(Peripheral.kt:16)

The issue is related to AtomicFU which seems is not setting up its dependencies properly.

As workaround I had to add it to commonMain code -> implementation("org.jetbrains.kotlinx:atomicfu:0.21.0") even if the consumer project of kable is not using the AtomicFU.

Please see the following related topic MobileNativeFoundation/Store#503.

@twyatt
Copy link
Member

twyatt commented Jul 5, 2023

Thanks for the report! I've reproduced this issue in SensorTag sample app by upgrading Kable from 0.24.0 to the latest main (which has an AtomicFU version bump).

Stacktrace
FATAL EXCEPTION: main
Process: com.juul.sensortag, PID: 10928
java.lang.NoClassDefFoundError: Failed resolution of: Lkotlinx/atomicfu/AtomicFU;
	at com.juul.kable.BluetoothDeviceAndroidPeripheral.<init>(BluetoothDeviceAndroidPeripheral.kt:112)
	at com.juul.kable.PeripheralKt.peripheral(Peripheral.kt:30)
	at com.juul.kable.PeripheralKt.peripheral(Peripheral.kt:46)
	at com.juul.kable.PeripheralKt.peripheral$default(Peripheral.kt:41)
	at com.juul.sensortag.features.sensor.SensorViewModel.<init>(SensorViewModel.kt:85)
	at com.juul.sensortag.features.sensor.SensorActivity$viewModel$2$1.create(SensorActivity.kt:48)
	at androidx.lifecycle.ViewModelProvider$Factory$-CC.$default$create(ViewModelProvider.kt:83)
	at com.juul.sensortag.features.sensor.SensorActivity$viewModel$2$1.create(Unknown Source:0)
	at androidx.lifecycle.ViewModelProvider.get(ViewModelProvider.kt:187)
	at androidx.lifecycle.ViewModelProvider.get(ViewModelProvider.kt:153)
	at androidx.lifecycle.ViewModelLazy.getValue(ViewModelLazy.kt:53)
	at androidx.lifecycle.ViewModelLazy.getValue(ViewModelLazy.kt:35)
	at com.juul.sensortag.features.sensor.SensorActivity.getViewModel(SensorActivity.kt:44)
	at com.juul.sensortag.features.sensor.SensorActivity.access$getViewModel(SensorActivity.kt:41)
	at com.juul.sensortag.features.sensor.SensorActivity$onCreate$1$1$1$1.invoke(SensorActivity.kt:67)
	at com.juul.sensortag.features.sensor.SensorActivity$onCreate$1$1$1$1.invoke(SensorActivity.kt:65)
	at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107)
	at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
	at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:228)
	at androidx.compose.material.TextKt.ProvideTextStyle(Text.kt:363)
	at com.juul.sensortag.features.sensor.SensorActivity$onCreate$1$1.invoke(SensorActivity.kt:63)
	at com.juul.sensortag.features.sensor.SensorActivity$onCreate$1$1.invoke(SensorActivity.kt:56)
	at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107)
	at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
	at androidx.compose.material.MaterialTheme_androidKt.PlatformMaterialTheme(MaterialTheme.android.kt:23)
	at androidx.compose.material.MaterialThemeKt$MaterialTheme$1$1.invoke(MaterialTheme.kt:82)
	at androidx.compose.material.MaterialThemeKt$MaterialTheme$1$1.invoke(MaterialTheme.kt:81)
	at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107)
	at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
	at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:228)
	at androidx.compose.material.TextKt.ProvideTextStyle(Text.kt:363)
	at androidx.compose.material.MaterialThemeKt$MaterialTheme$1.invoke(MaterialTheme.kt:81)
	at androidx.compose.material.MaterialThemeKt$MaterialTheme$1.invoke(MaterialTheme.kt:80)
	at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107)
	at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
	at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:228)
	at androidx.compose.material.MaterialThemeKt.MaterialTheme(MaterialTheme.kt:72)
	at com.juul.sensortag.ThemeKt.AppTheme(Theme.kt:17)
	at com.juul.sensortag.features.sensor.SensorActivity$onCreate$1.invoke(SensorActivity.kt:56)
	at com.juul.sensortag.features.sensor.SensorActivity$onCreate$1.invoke(SensorActivity.kt:55)
	at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107)
	at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
	at androidx.compose.ui.platform.ComposeView.Content(ComposeView.android.kt:428)
	at androidx.compose.ui.platform.AbstractComposeView$ensureCompositionCreated$1.invoke(ComposeView.android.kt:252)
	at androidx.compose.ui.platform.AbstractComposeView$ensureCompositionCreated$1.invoke(ComposeView.android.kt:251)
	at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107)
	at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
	at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:228)
	at androidx.compose.ui.platform.CompositionLocalsKt.ProvideCommonCompositionLocals(CompositionLocals.kt:194)
	at androidx.compose.ui.platform.AndroidCompositionLocals_androidKt$ProvideAndroidCompositionLocals$3.invoke(AndroidCompositionLocals.android.kt:123)
	at androidx.compose.ui.platform.AndroidCompositionLocals_androidKt$ProvideAndroidCompositionLocals$3.invoke(AndroidCompositionLocals.android.kt:122)
	at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107)
	at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
	at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:228)
	at androidx.compose.ui.platform.AndroidCompositionLocals_androidKt.ProvideAndroidCompositionLocals(AndroidCompositionLocals.android.kt:114)
	at androidx.compose.ui.platform.WrappedComposition$setContent$1$1$2.invoke(Wrapper.android.kt:156)
	at androidx.compose.ui.platform.WrappedComposition$setContent$1$1$2.invoke(Wrapper.android.kt:155)
	at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107)
	at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
	at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:228)
	at androidx.compose.ui.platform.WrappedComposition$setContent$1$1.invoke(Wrapper.android.kt:155)
	at androidx.compose.ui.platform.WrappedComposition$setContent$1$1.invoke(Wrapper.android.kt:140)
	at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107)
	at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
	at androidx.compose.runtime.ActualJvm_jvmKt.invokeComposable(ActualJvm.jvm.kt:78)
	at androidx.compose.runtime.ComposerImpl$doCompose$2$5.invoke(Composer.kt:3373)
	at androidx.compose.runtime.ComposerImpl$doCompose$2$5.invoke(Composer.kt:3363)
	at androidx.compose.runtime.SnapshotStateKt__DerivedStateKt.observeDerivedStateRecalculations(DerivedState.kt:341)
	at androidx.compose.runtime.SnapshotStateKt.observeDerivedStateRecalculations(Unknown Source:1)
	at androidx.compose.runtime.ComposerImpl.doCompose(Composer.kt:3363)
	at androidx.compose.runtime.ComposerImpl.composeContent$runtime_release(Composer.kt:3298)
	at androidx.compose.runtime.CompositionImpl.composeContent(Composition.kt:587)
	at androidx.compose.runtime.Recomposer.composeInitial$runtime_release(Recomposer.kt:966)
	at androidx.compose.runtime.CompositionImpl.setContent(Composition.kt:519)
	at androidx.compose.ui.platform.WrappedComposition$setContent$1.invoke(Wrapper.android.kt:140)
	at androidx.compose.ui.platform.WrappedComposition$setContent$1.invoke(Wrapper.android.kt:131)
	at androidx.compose.ui.platform.AndroidComposeView.setOnViewTreeOwnersAvailable(AndroidComposeView.android.kt:1099)
	at androidx.compose.ui.platform.WrappedComposition.setContent(Wrapper.android.kt:131)
	at androidx.compose.ui.platform.WrappedComposition.onStateChanged(Wrapper.android.kt:181)
	at androidx.lifecycle.LifecycleRegistry$ObserverWithState.dispatchEvent(LifecycleRegistry.kt:314)
	at androidx.lifecycle.LifecycleRegistry.addObserver(LifecycleRegistry.kt:192)
	at androidx.compose.ui.platform.WrappedComposition$setContent$1.invoke(Wrapper.android.kt:138)
	at androidx.compose.ui.platform.WrappedComposition$setContent$1.invoke(Wrapper.android.kt:131)
	at androidx.compose.ui.platform.AndroidComposeView.onAttachedToWindow(AndroidComposeView.android.kt:1174)
	at android.view.View.dispatchAttachedToWindow(View.java:21308)
	at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3491)
	at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3498)
	at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3498)
	at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3498)
	at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3498)
	at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2879)
	at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:2350)
	at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:9194)
	at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1231)
	at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1239)
	at android.view.Choreographer.doCallbacks(Choreographer.java:899)
	at android.view.Choreographer.doFrame(Choreographer.java:832)
	at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1214)
	at android.os.Handler.handleCallback(Handler.java:942)
	at android.os.Handler.dispatchMessage(Handler.java:99)
	at android.os.Looper.loopOnce(Looper.java:201)
	at android.os.Looper.loop(Looper.java:288)
	at android.app.ActivityThread.main(ActivityThread.java:7884)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
Caused by: java.lang.ClassNotFoundException: Didn't find class "kotlinx.atomicfu.AtomicFU" on path: DexPathList[[zip file "/data/app/~~tydGIhDT8PdB3MUPQsniOw==/com.juul.sensortag-_nPVcosmkKrgwTBOfJurKQ==/base.apk"],nativeLibraryDirectories=[/data/app/~~tydGIhDT8PdB3MUPQsniOw==/com.juul.sensortag-_nPVcosmkKrgwTBOfJurKQ==/lib/arm64, /system/lib64, /system_ext/lib64]]
	at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:259)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
	... 106 more

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants