I am building an Android app based on a online course from PL-Coding, I wanted to implement the new compose navigation version (2.8.0-alpha08) with type safe navigation arguments. The problem is that it crashes as soon as I launch a screen with TextFieldState (experimental API from compose). It works fine with version 2.7.7 of compose navigation, but crashes with versions 2.8.0-alpha08 and 2.8.0-beta01 (even without using the new navigation).
I get this error :
FATAL EXCEPTION: main
Process: com.jlahougue.runique, PID: 10474
java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/compose/foundation/text2/input/TextFieldState;
at com.jlahougue.auth.presentation.register.RegisterState.<init>(RegisterState.kt:10)
at com.jlahougue.auth.presentation.register.RegisterViewModel.<init>(RegisterViewModel.kt:20)
at com.jlahougue.auth.presentation.di.AuthViewModelModuleKt$authViewModelModule$lambda$0$$inlined$viewModelOf$default$1.invoke(ViewModelOf.kt:231)
at com.jlahougue.auth.presentation.di.AuthViewModelModuleKt$authViewModelModule$lambda$0$$inlined$viewModelOf$default$1.invoke(ViewModelOf.kt:55)
at org.koin.core.instance.InstanceFactory.create(InstanceFactory.kt:50)
at org.koin.core.instance.FactoryInstanceFactory.get(FactoryInstanceFactory.kt:38)
at org.koin.core.registry.InstanceRegistry.resolveInstance$koin_core(InstanceRegistry.kt:109)
at org.koin.core.scope.Scope.resolveValue(Scope.kt:247)
at org.koin.core.scope.Scope.resolveInstance(Scope.kt:233)
at org.koin.core.scope.Scope.get(Scope.kt:212)
at org.koin.androidx.viewmodel.factory.KoinViewModelFactory.create(KoinViewModelFactory.kt:25)
at androidx.lifecycle.ViewModelProvider$Factory.create(ViewModelProvider.android.kt:158)
at androidx.lifecycle.viewmodel.ViewModelProviderImpl.getViewModel$lifecycle_viewmodel_release(ViewModelProviderImpl.kt:69)
at androidx.lifecycle.viewmodel.ViewModelProviderImpl.getViewModel$lifecycle_viewmodel_release$default(ViewModelProviderImpl.kt:47)
at androidx.lifecycle.ViewModelProvider.get(ViewModelProvider.android.kt:91)
at androidx.lifecycle.ViewModelProvider.get(ViewModelProvider.android.kt:109)
at org.koin.androidx.viewmodel.GetViewModelKt.resolveViewModel(GetViewModel.kt:43)
at com.jlahougue.auth.presentation.register.RegisterScreenKt.RegisterScreenRoot(RegisterScreen.kt:227)
at com.jlahougue.runique.NavigationRootKt$authGraph$1$2.invoke(NavigationRoot.kt:42)
at com.jlahougue.runique.NavigationRootKt$authGraph$1$2.invoke(NavigationRoot.kt:41)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:139)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35)
at androidx.navigation.compose.NavHostKt$NavHost$32$1.invoke(NavHost.kt:613)
at androidx.navigation.compose.NavHostKt$NavHost$32$1.invoke(NavHost.kt:611)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:109)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35)
at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:401)
at androidx.compose.runtime.saveable.SaveableStateHolderImpl.SaveableStateProvider(SaveableStateHolder.kt:85)
at androidx.navigation.compose.NavBackStackEntryProviderKt.SaveableStateProvider(NavBackStackEntryProvider.kt:65)
at androidx.navigation.compose.NavBackStackEntryProviderKt.access$SaveableStateProvider(NavBackStackEntryProvider.kt:1)
at androidx.navigation.compose.NavBackStackEntryProviderKt$LocalOwnersProvider$1.invoke(NavBackStackEntryProvider.kt:52)
at androidx.navigation.compose.NavBackStackEntryProviderKt$LocalOwnersProvider$1.invoke(NavBackStackEntryProvider.kt:51)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:109)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35)
at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:380)
at androidx.navigation.compose.NavBackStackEntryProviderKt.LocalOwnersProvider(NavBackStackEntryProvider.kt:47)
at androidx.navigation.compose.NavHostKt$NavHost$32.invoke(NavHost.kt:611)
at androidx.navigation.compose.NavHostKt$NavHost$32.invoke(NavHost.kt:594)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:139)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35)
at androidx.compose.animation.AnimatedContentKt$AnimatedContent$6$1$5.invoke(AnimatedContent.kt:803)
at androidx.compose.animation.AnimatedContentKt$AnimatedContent$6$1$5.invoke(AnimatedContent.kt:792)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:118)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35)
at androidx.compose.animation.AnimatedVisibilityKt.AnimatedEnterExitImpl(AnimatedVisibility.kt:771)
at androidx.compose.animation.AnimatedContentKt$AnimatedContent$6$1.invoke(AnimatedContent.kt:774)
at androidx.compose.animation.AnimatedContentKt$AnimatedContent$6$1.invoke(AnimatedContent.kt:757)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:109)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35)
at androidx.compose.animation.AnimatedContentKt.AnimatedContent(AnimatedContent.kt:816)
at androidx.navigation.compose.NavHostKt.NavHost(NavHost.kt:571)
at androidx.navigation.compose.NavHostKt$NavHost$34.invoke(Unknown Source:29)
at androidx.navigation.compose.NavHostKt$NavHost$34.invoke(Unknown Source:10)
at androidx.compose.runtime.RecomposeScopeImpl.compose(RecomposeScopeImpl.kt:192)
at androidx.compose.runtime.ComposerImpl.recomposeToGroupEnd(Composer.kt:2823)
at androidx.compose.runtime.ComposerImpl.skipCurrentGroup(Composer.kt:3114)
at androidx.compose.runtime.ComposerImpl.doCompose(Composer.kt:3605)
at androidx.compose.runtime.ComposerImpl.recompose$runtime_release(Composer.kt:3550)
at androidx.compose.runtime.CompositionImpl.recompose(Composition.kt:948)
at androidx.compose.runtime.Recomposer.performRecompose(Recomposer.kt:1198)
at androidx.compose.runtime.Recomposer.access$performRecompose(Recomposer.kt:132)
at androidx.compose.runtime.Recomposer$runRecomposeAndApplyChanges$2$1.invoke(Recomposer.kt:609)
at androidx.compose.runtime.Recomposer$runRecomposeAndApplyChanges$2$1.invoke(Recomposer.kt:578)
at androidx.compose.ui.platform.AndroidUiFrameClock$withFrameNanos$2$callback$1.doFrame(AndroidUiFrameClock.android.kt:41)
at androidx.compose.ui.platform.AndroidUiDispatcher.performFrameDispatch(AndroidUiDispatcher.android.kt:109)
at androidx.compose.ui.platform.AndroidUiDispatcher.access$performFrameDispatch(AndroidUiDispatcher.android.kt:41)
at androidx.compose.ui.platform.AndroidUiDispatcher$dispatchCallback$1.doFrame(AndroidUiDispatcher.android.kt:69)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1035)
at android.view.Choreographer.doCallbacks(Choreographer.java:845)
at android.view.Choreographer.doFrame(Choreographer.java:775)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1022)
at android.os.Handler.handleCallback(Handler.java:938)
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:7839)
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:1003)
Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [androidx.compose.runtime.PausableMonotonicFrameClock@46da157, androidx.compose.ui.platform.MotionDurationScaleImpl@a206444, StandaloneCoroutine{Cancelling}@eef992d, AndroidUiDispatcher@27e1e62]
Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.compose.foundation.text2.input.TextFieldState" on path: DexPathList[[zip file "/data/app/~~hqBtIZBlu44CWRUpMilOjw==/com.jlahougue.runique-IDMmmJEiS3W7iNOyHla66Q==/base.apk"],nativeLibraryDirectories=[/data/app/~~hqBtIZBlu44CWRUpMilOjw==/com.jlahougue.runique-IDMmmJEiS3W7iNOyHla66Q==/lib/x86_64, /data/app/~~hqBtIZBlu44CWRUpMilOjw==/com.jlahougue.runique-IDMmmJEiS3W7iNOyHla66Q==/base.apk!/lib/x86_64, /system/lib64, /system_ext/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:218)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
... 79 more
Has anyone encountered this error ?
I'm using the BOM 2024.05.00
navigation-compose
versions starting from 2.8.0-alpha01
require Compose 1.7.0 (in varying alpha releases). Your Compose Bom provides only the version 1.6.7. navigation-compose
will transitively update the version of the Compose dependencies it uses but will leave the others as they were. This results in some of your Compose components using version 1.6.7, others using some alpha versions of 1.7.0. This incompatibility causes your app to crash.
For version navigation-compose:2.8.0-beta01
the appropriate version for most Compose artifacts should be 1.7.0-alpha03
. Google does not provide an official BOM for unstable versions, so you must either go back to specifiying versions manually for each dependency or use some third-party BOM for Compose alpha versions like Chris Banes' Compose BOM (alpha edition). dev.chrisbanes.compose:compose-bom:2024.02.00-alpha02
is the first version that uses alpha03.
There is now an official BOM for alpha versions: androidx.compose:compose-bom-alpha
.
Please note the API changes in Compose Foundation 1.7.0-alpha03, they may be relevant for you.
This may also introduce some new version incompatibilities with your other dependencies. Be aware.