accompanist: [Navigation Material] Crash after updating to Accompanist 0.24.8-beta (+ Compose 1.2.0-beta01) and later versions

Description Cannot start application. It crashes immediately. Stacktrace:

2022-05-12 16:49:44.541 30438-30438/com.mycompany.myapp E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.mycompany.myapp, PID: 30438
    java.util.NoSuchElementException: List contains no element matching the predicate.
        at com.google.accompanist.navigation.animation.AnimatedNavHostKt$AnimatedNavHost$9.invoke(AnimatedNavHost.kt:249)
        at com.google.accompanist.navigation.animation.AnimatedNavHostKt$AnimatedNavHost$9.invoke(AnimatedNavHost.kt:201)
        at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:135)
        at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
        at androidx.compose.animation.AnimatedContentKt$AnimatedContent$5$1$4.invoke(AnimatedContent.kt:658)
        at androidx.compose.animation.AnimatedContentKt$AnimatedContent$5$1$4.invoke(AnimatedContent.kt:648)
        at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:116)
        at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
        at androidx.compose.animation.AnimatedVisibilityKt.AnimatedEnterExitImpl(AnimatedVisibility.kt:937)
        at androidx.compose.animation.AnimatedVisibilityKt.AnimatedVisibility(AnimatedVisibility.kt:606)
        at androidx.compose.animation.AnimatedContentKt$AnimatedContent$5$1.invoke(AnimatedContent.kt:638)
        at androidx.compose.animation.AnimatedContentKt$AnimatedContent$5$1.invoke(AnimatedContent.kt:625)
        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.animation.AnimatedContentKt.AnimatedContent(AnimatedContent.kt:671)
        at com.google.accompanist.navigation.animation.AnimatedNavHostKt.AnimatedNavHost(AnimatedNavHost.kt:196)
        at com.google.accompanist.navigation.animation.AnimatedNavHostKt$AnimatedNavHost$11.invoke(Unknown Source:23)
        at com.google.accompanist.navigation.animation.AnimatedNavHostKt$AnimatedNavHost$11.invoke(Unknown Source:10)
        at androidx.compose.runtime.RecomposeScopeImpl.compose(RecomposeScopeImpl.kt:142)
        at androidx.compose.runtime.ComposerImpl.recomposeToGroupEnd(Composer.kt:2350)
        at androidx.compose.runtime.ComposerImpl.skipCurrentGroup(Composer.kt:2610)
        at androidx.compose.runtime.ComposerImpl$doCompose$2$5.invoke(Composer.kt:3196)
        at androidx.compose.runtime.ComposerImpl$doCompose$2$5.invoke(Composer.kt:3174)
        at androidx.compose.runtime.SnapshotStateKt__DerivedStateKt.observeDerivedStateRecalculations(DerivedState.kt:252)
        at androidx.compose.runtime.SnapshotStateKt.observeDerivedStateRecalculations(Unknown Source:1)
        at androidx.compose.runtime.ComposerImpl.doCompose(Composer.kt:3174)
        at androidx.compose.runtime.ComposerImpl.recompose$runtime_release(Composer.kt:3140)
        at androidx.compose.runtime.CompositionImpl.recompose(Composition.kt:722)
        at androidx.compose.runtime.Recomposer.performRecompose(Recomposer.kt:876)
        at androidx.compose.runtime.Recomposer.access$performRecompose(Recomposer.kt:107)
        at androidx.compose.runtime.Recomposer$runRecomposeAndApplyChanges$2$2.invoke(Recomposer.kt:485)
        at androidx.compose.runtime.Recomposer$runRecomposeAndApplyChanges$2$2.invoke(Recomposer.kt:454)
        at androidx.compose.ui.platform.AndroidUiFrameClock$withFrameNanos$2$callback$1.doFrame(AndroidUiFrameClock.android.kt:34)
        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:1106)
        at android.view.Choreographer.doCallbacks(Choreographer.java:866)
        at android.view.Choreographer.doFrame(Choreographer.java:792)
        at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1092)
        at android.os.Handler.handleCallback(Handler.java:938)
2022-05-12 16:49:44.542 30438-30438/com.mycompany.myapp E/AndroidRuntime:     at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loopOnce(Looper.java:226)
        at android.os.Looper.loop(Looper.java:313)
        at android.app.ActivityThread.main(ActivityThread.java:8663)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:567)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)
    	Suppressed: kotlinx.coroutines.DiagnosticCoroutineContextException: [androidx.compose.runtime.PausableMonotonicFrameClock@c1b3624, androidx.compose.ui.platform.MotionDurationScaleImpl@5ed358d, StandaloneCoroutine{Cancelling}@45ef342, AndroidUiDispatcher@197df53]

Steps to reproduce Start the app

Expected behavior App starts

Additional context accompanist = “0.24.8-beta” androidx-activity-compose = “1.5.0-rc01” // Also tried with 1.4.1 with same results androidx-compose = “1.2.0-beta01”

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 13
  • Comments: 28

Commits related to this issue

Most upvoted comments

Why was this issue closed?

I tried with

Compose 1.2.0-beta03 Accompanist 0.24.11-rc Navigation Compose 2.5.0-rc02

And the issue above is still present.

Still an issue with:

accompanist = “0.24.9-beta” androidx-compose = “1.2.0-beta02”

Still an issue on:

compose = "1.2.0-rc02"
navigation = "2.5.0-rc02"
accompanist = "0.24.12-rc"

Also have this issue with version 0.24.8-beta onwards, including 0.24.11-rc. Downgrading to 0.24.7-alpha fixes that issue.

Tried with nav_version 2.5.0-rc02 and 2.4.2 - crashes on both.

This seems to be related to an issue in the base Navigation library. This issues has been fixed in the upcoming Navigation 2.5.0-rc02 release. Once the release is public, we can fix in accompanist. You can test this out by using a snapshot.

Edit: That fix was actually in NavHost directly and won’t fix this. Will need something AnimatedNavHost for this.

I can confirm that this other fix does not solve this problem.

These issues actually might just have the same error, but be different issues. Does anyone have a sample project that reproduces this?

I can reproduce it but the proprietary app I’m working on is quite big so it could be a big effort to try to extract a minimum reproducer. Maybe I would find the time for it, but I can’t make any promises.

I tried with:

  • Compose 1.2.0-beta03
  • Accompanist 0.24.10-beta
  • Navigation Compose 2.5.0-rc02
java.util.NoSuchElementException: List contains no element matching the predicate.
        at com.google.accompanist.navigation.animation.AnimatedNavHostKt$AnimatedNavHost$9.invoke(AnimatedNavHost.kt:249)