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

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

Closed
alixwar opened this issue May 12, 2022 · 28 comments · Fixed by jbw0033/accompanist#3 or #1243
Assignees

Comments

@alixwar
Copy link

alixwar commented May 12, 2022

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"

@alixwar
Copy link
Author

alixwar commented May 12, 2022

Update 1
I replaced AnimatedNavHost with an ordinary NavHost and then I get a completely empty view... So maybe this is a red herring from an accompanist perspective... But still, something is weird after updating the libraries...

Update 2
Confirmed to be accompanist that causes the issue. I downgraded accompanist only to 0.24.7-alpha and then everything works as expected.

@Jafar-Al-Rashid
Copy link

I had a similar crash, reverting accomponist back to 0.24.7-alpha worked for me
Using 1.2.0-beta01

@lilemma
Copy link

lilemma commented May 16, 2022

I experienced the same crash. Also reverting accompanist back to 0.24.6-alpha fixed the issue for me.

@Feinate
Copy link

Feinate commented May 16, 2022

I had similiar crash, but with normal navigation (NavHost)
E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.lol, PID: 17554 java.util.NoSuchElementException: List contains no element matching the predicate. at androidx.navigation.compose.NavHostKt$NavHost$4.invoke(NavHost.kt:180) at androidx.navigation.compose.NavHostKt$NavHost$4.invoke(NavHost.kt:141) at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:116) at androidx.compose.runtime.internal.ComposableLambdaImpl$invoke$1.invoke(ComposableLambda.jvm.kt:127) at androidx.compose.runtime.internal.ComposableLambdaImpl$invoke$1.invoke(ComposableLambda.jvm.kt:127) at androidx.compose.runtime.RecomposeScopeImpl.compose(RecomposeScopeImpl.kt:142) at androidx.compose.runtime.ComposerImpl.recomposeToGroupEnd(Composer.kt:2350) at androidx.compose.runtime.ComposerImpl.skipToGroupEnd(Composer.kt:2633) at androidx.compose.animation.CrossfadeKt.Crossfade(Crossfade.kt:56) at androidx.navigation.compose.NavHostKt.NavHost(NavHost.kt:141) at androidx.navigation.compose.NavHostKt$NavHost$5.invoke(Unknown Source:13) at androidx.navigation.compose.NavHostKt$NavHost$5.invoke(Unknown Source:8) 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:970) at android.view.Choreographer.doCallbacks(Choreographer.java:796) at android.view.Choreographer.doFrame(Choreographer.java:727) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:957) at android.os.Handler.handleCallback(Handler.java:938) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:223) at android.app.ActivityThread.main(ActivityThread.java:7656) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947) Suppressed: kotlinx.coroutines.DiagnosticCoroutineContextException: [androidx.compose.runtime.PausableMonotonicFrameClock@2370c24, androidx.compose.ui.platform.MotionDurationScaleImpl@efb538d, StandaloneCoroutine{Cancelling}@85b942, AndroidUiDispatcher@26e2d53]

@Feinate
Copy link

Feinate commented May 16, 2022

The problem is related To normal Navigation Library -> android/compose-samples#805
Try to Downgrad to : "androidx.navigation:navigation-compose:2.4.2"

@alixwar
Copy link
Author

alixwar commented May 16, 2022

The problem is related To normal Navigation Library -> android/compose-samples#805 Try to Downgrad to : "androidx.navigation:navigation-compose:2.4.2"

I actually already used "androidx.navigation:navigation-compose:2.4.1" before/after upgrading so it seems unrelated to the issue that I reported. But I will look into updating this as well - this dependency fell off my radar

@Feinate
Copy link

Feinate commented May 16, 2022

The problem is related To normal Navigation Library -> android/compose-samples#805 Try to Downgrad to : "androidx.navigation:navigation-compose:2.4.2"

I actually already used "androidx.navigation:navigation-compose:2.4.1" before/after upgrading so it seems unrelated to the issue that I reported. But I will look into updating this as well - this dependency fell off my radar

Yes, bc Accompanist is based on Normal Navigation LIbrary so.. if there is a problem in The normal version, there'll be in Accompanist too.

@alixwar
Copy link
Author

alixwar commented May 19, 2022

Still an issue with:

accompanist = "0.24.9-beta"
androidx-compose = "1.2.0-beta02"

@rhariskumar3
Copy link

rhariskumar3 commented Jun 5, 2022

Still an issue with:

accompanist = "0.24.10-beta"
androidx-compose = "1.2.0-beta02"

Crash Location Screenshot

From Above Screenshot Code, visibleEntries.lastOrNull() produces different result in same block.

@luiscurini
Copy link

We have the same issue with:

accompanist = "0.24.10-beta"
androidx-compose = "1.2.0-beta03"

For us, it's caused when a custom argument is used:

  composable(
                route = Screen.Details.route,
                arguments = listOf(
                    navArgument(Constant.CUSTOM_TYPE_ARGUMENT_KEY) {
                        type = CustomNavType()
                    }
                ),
              )  

if I comment out the argument parameter, it works but of course I can't get that data.

We don't have this issue with:
accompanist = "0.24.6-alpha"
androidx-compose = "1.2.0-beta01"
navigation-compose = "2.5.0-rc01"

@eglogis
Copy link

eglogis commented Jun 13, 2022

Hello, the same thing happened to me, and I have "fixed" it by downgrading accompanist to 0.24.7-alpha. Thank you!

@jbw0033
Copy link
Collaborator

jbw0033 commented Jun 13, 2022

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.

@jbw0033
Copy link
Collaborator

jbw0033 commented Jun 13, 2022

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

@alwa
Copy link

alwa commented Jun 14, 2022

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)

@alixwar alixwar changed the title [Navigation Animation] Crash after updating to Accompanist 0.24.8-beta (+ Compose 1.2.0-beta01) [Navigation Material] Crash after updating to Accompanist 0.24.8-beta (+ Compose 1.2.0-beta01) and later versions Jun 14, 2022
@luiscurini
Copy link

Still same issue here:

Compose 1.2.0-beta03
Accompanist 0.24.10-beta
Navigation Compose 2.5.0-rc02

Full stacktrace:

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:2351)
        at androidx.compose.runtime.ComposerImpl.skipToGroupEnd(Composer.kt:2634)
        at com.ourapp.app.ui.upload.navigation.UploadNavGraphKt$UploadNavGraph$1.invoke(UploadNavGraph.kt:368)
        at com.ourapp.app.ui.upload.navigation.UploadNavGraphKt$UploadNavGraph$1.invoke(UploadNavGraph.kt:88)
        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.ModalBottomSheetKt$ModalBottomSheetLayout$1.invoke(ModalBottomSheet.kt:330)
        at androidx.compose.material.ModalBottomSheetKt$ModalBottomSheetLayout$1.invoke(ModalBottomSheet.kt:326)
        at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:116)
        at androidx.compose.runtime.internal.ComposableLambdaImpl$invoke$1.invoke(ComposableLambda.jvm.kt:127)
        at androidx.compose.runtime.internal.ComposableLambdaImpl$invoke$1.invoke(ComposableLambda.jvm.kt:127)
        at androidx.compose.runtime.RecomposeScopeImpl.compose(RecomposeScopeImpl.kt:142)
        at androidx.compose.runtime.ComposerImpl.recomposeToGroupEnd(Composer.kt:2351)
        at androidx.compose.runtime.ComposerImpl.skipCurrentGroup(Composer.kt:2611)
        at androidx.compose.runtime.ComposerImpl$doCompose$2$5.invoke(Composer.kt:3198)
        at androidx.compose.runtime.ComposerImpl$doCompose$2$5.invoke(Composer.kt:3176)
        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:3176)
        at androidx.compose.runtime.ComposerImpl.recompose$runtime_release(Composer.kt:3141)
        at androidx.compose.runtime.CompositionImpl.recompose(Composition.kt:727)

@luiscurini
Copy link

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.

@alixwar
Copy link
Author

alixwar commented Jun 16, 2022

I can report the same result as @luiscurini . It's still an issue when these dependencies are used.

Stacktrace:

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:939)
        at androidx.compose.animation.AnimatedVisibilityKt.AnimatedVisibility(AnimatedVisibility.kt:607)
        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)

Please reopen @bentrengrove

@bentrengrove bentrengrove reopened this Jun 16, 2022
@alixwar
Copy link
Author

alixwar commented Jun 18, 2022

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

It could be that this has the same root cause as #1175

In that case there is a sample project to reproduce the issue: #1175 (comment)

@Przeszaf
Copy link

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.

@amal
Copy link

amal commented Jun 20, 2022

I'm having Navigation 2.5.0-rc02 and still getting NoSuchElementException crash.

compose = "1.2.0-rc01"
navigation = "2.5.0-rc02"
accompanist = "0.24.9-beta"

Stacktrace:

E/AndroidRuntime: FATAL EXCEPTION: main
    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:939)
        at androidx.compose.animation.AnimatedVisibilityKt.AnimatedVisibility(AnimatedVisibility.kt:607)
        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:2351)
        at androidx.compose.runtime.ComposerImpl.skipCurrentGroup(Composer.kt:2618)
        at androidx.compose.runtime.ComposerImpl$doCompose$2$5.invoke(Composer.kt:3205)
        at androidx.compose.runtime.ComposerImpl$doCompose$2$5.invoke(Composer.kt:3183)
        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:3183)
        at androidx.compose.runtime.ComposerImpl.recompose$runtime_release(Composer.kt:3148)
        at androidx.compose.runtime.CompositionImpl.recompose(Composition.kt:739)
        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:1056)
        at android.view.Choreographer.doCallbacks(Choreographer.java:880)
        at android.view.Choreographer.doFrame(Choreographer.java:809)
        at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1043)
        at android.os.Handler.handleCallback(Handler.java:938)
E/AndroidRuntime:     at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:236)
        at android.app.ActivityThread.main(ActivityThread.java:7889)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:600)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:967)
    	Suppressed: kotlinx.coroutines.DiagnosticCoroutineContextException: [androidx.compose.runtime.PausableMonotonicFrameClock@e75298d, androidx.compose.ui.platform.MotionDurationScaleImpl@a99d742, StandaloneCoroutine{Cancelling}@222f353, AndroidUiDispatcher@4371490]

@alixwar
Copy link
Author

alixwar commented Jun 28, 2022

Still an issue on:

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

@agent10
Copy link

agent10 commented Jul 2, 2022

Got the same crash on the latest versions

@Amagi82
Copy link

Amagi82 commented Jul 7, 2022

Still an issue with 0.24.13-rc

@polivmi1
Copy link

polivmi1 commented Jul 8, 2022

I have added https://issuetracker.google.com/issues/238336704 that didn't include the animate nav host because they have closed the previous issue and nobody is answering the comments.
Hopefully, this gets fixed soon, because the library updates are unusable.
Please star the issue to get the Google team's attention.

@jbw0033
Copy link
Collaborator

jbw0033 commented Jul 11, 2022

The issue in #1175 is unrelated to this so we are still looking for a sample for reproducing this issue.

polivmi1 added a commit to polivmi1/sample1162 that referenced this issue Jul 12, 2022
@polivmi1
Copy link

polivmi1 commented Jul 12, 2022

@jbw0033 I have created a sample project: https://github.com/polivmi1/sample1162
There is a drawer, where if you click Screen2, it will crash with this crash. It won't crash if you only click the button on the screens. You have to use the drawer, which triggers it through viewmodel.

jbw0033 pushed a commit to jbw0033/accompanist that referenced this issue Jul 12, 2022
Since moving to using visibleEntries, if you change your start
destination dynamically, instead of dropping the graph and rebuilding,
the AnimatedNavHost crashes.

The reason for this crash is that setting the graph synchronously pops
the entire back stack, which clears all of the visibleEntries so there
is a frame in AnimatedNavHost where it fails to find any of the old
entries.

We should move setNavGraph over to using the popWithTransition function,
but there is pre-req works that needs to be done. So as a stop gap, we
will return null from visibleEntries and disable the animations on
AnimatedNavHost.

Fixes google#1162
@alixwar
Copy link
Author

alixwar commented Jul 27, 2022

I cannot reproduce this issue on a Samsung Galaxy S21 (Android 12) after bumping my dependencies:

  • Accompanist 0.24.7-alpha -> 0.24.13-rc
  • Activity-compose 1.5.0-RC01 -> 1.5.0
  • Compose 1.2.0-beta02 -> 1.2.0-rc03
  • Compose compiler 1.2.0-beta02 -> 1.2.0
  • Navigation 2.5.0-rc01 -> 2.5.0

However, I could still reproduce the error on a Google Pixel 6 (Android 13 beta) + prelaunch report from Google Play on various devices (Google Pixel models + Samsung Galaxy S20 / Android 10):

Fatal Exception: 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:939)
       at androidx.compose.animation.AnimatedVisibilityKt.AnimatedVisibility(AnimatedVisibility.kt:607)
       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(:23)
       at com.google.accompanist.navigation.animation.AnimatedNavHostKt$AnimatedNavHost$11.invoke(:8)
       at androidx.compose.runtime.RecomposeScopeImpl.compose(RecomposeScopeImpl.kt:145)
       at androidx.compose.runtime.ComposerImpl.recomposeToGroupEnd(Composer.kt:2351)
       at androidx.compose.runtime.ComposerImpl.skipCurrentGroup(Composer.kt:2618)
       at androidx.compose.runtime.ComposerImpl$doCompose$2$5.invoke(Composer.kt:3205)
       at androidx.compose.runtime.ComposerImpl$doCompose$2$5.invoke(Composer.kt:3183)
       at androidx.compose.runtime.SnapshotStateKt__DerivedStateKt.observeDerivedStateRecalculations(DerivedState.kt:252)
       at androidx.compose.runtime.SnapshotStateKt.observeDerivedStateRecalculations(:1)
       at androidx.compose.runtime.ComposerImpl.doCompose(Composer.kt:3183)
       at androidx.compose.runtime.ComposerImpl.recompose$runtime_release(Composer.kt:3148)
       at androidx.compose.runtime.CompositionImpl.recompose(Composition.kt:746)
       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:970)
       at android.view.Choreographer.doCallbacks(Choreographer.java:796)
       at android.view.Choreographer.doFrame(Choreographer.java:727)
       at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:957)
       at android.os.Handler.handleCallback(Handler.java:938)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loop(Looper.java:223)
       at android.app.ActivityThread.main(ActivityThread.java:7664)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947) 
       

@alixwar
Copy link
Author

alixwar commented Aug 1, 2022

After more library updates I can no longer reproduce this issue at all.

Relevant (somewhat) library updates I did to fix the problem completely:

  • Accompanist 0.24.13-rc -> 0.25.0
  • Compose 1.2.0-rc03 -> 1.2.0
  • Navigation 2.5.0 -> 2.5.1
  • KotlinX coroutines 1.6.1 -> 1.6.4
  • AndroidX Annotation 1.3.0 -> 1.4.0
  • Appcompat 1.4.1 -> 1.4.2
  • Activity-compose 1.5.0 -> 1.5.1
  • Constraint-layout compose 1.0.0 -> 1.0.1
  • AndroidX lifecycle 2.4.1 -> 2.5.1

Probably fixed in #1243

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment