raamcosta / compose-destinations

Annotation processing library for type-safe Jetpack Compose navigation with no boilerplate.
https://composedestinations.rafaelcosta.xyz
Apache License 2.0
3.19k stars 132 forks source link

NoSuchElementException: List contains no element matching the predicate. #184

Closed RoustamManookian closed 2 years ago

RoustamManookian commented 2 years ago

Hi

I updated the Android Studio to "Android Studion Chipmunk - 2021.2.1 Patch1" and now I get a NoSuchElementException: List contains no element matching the predicate.

I am not sure that the problem is in the "navigation destination" package but it seems like that, because I commented all the other lines and only when I uncomment the line where it navigates to the next screen I ger the exception.

java.util.NoSuchElementException: List contains no element matching the predicate. at androidx.navigation.compose.NavHostKt$NavHost$4.invoke(NavHost.kt:181) 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(ComposableLambda.jvm.kt:34) at androidx.compose.animation.CrossfadeKt$Crossfade$4$1.invoke(Crossfade.kt:115) at androidx.compose.animation.CrossfadeKt$Crossfade$4$1.invoke(Crossfade.kt:110) 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.CrossfadeKt.Crossfade(Crossfade.kt:124) at androidx.compose.animation.CrossfadeKt.Crossfade(Crossfade.kt:55) 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: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: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) 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@5545588, StandaloneCoroutine{Cancelling}@6280b21, AndroidUiDispatcher@ef6fb46]

RoustamManookian commented 2 years ago

I switched back to Kotlin

id 'com.google.devtools.ksp' version '1.6.10-1.0.2'

raamcosta commented 2 years ago

Did this solve the issue? I really don’t think this is something caused by compose destinations. It’s either a bug with navigation in general or maybe version mismatch.

RoustamManookian commented 2 years ago

Yes, but I'm working with Kotlin version 1.6.10

raamcosta commented 2 years ago

This was actually already reported, I just noticed. It is indeed an issue with jetpack compose navigation.

Duplicate of https://github.com/raamcosta/compose-destinations/issues/166

raamcosta commented 2 years ago

Can you tell me the versions of Kotlin, compose, compose compiler, and compose destinations that was not working?

jmadaminov commented 2 years ago

kotlin = "1.7.0" compose = 1.2.0-rc03 composeCompiler = "1.2.0" composeNavigation = 2.5.0 compose-destinations = 1.6.13-beta accompanist = 0.24.13-rc

also having the exact same issue

raamcosta commented 2 years ago

compose = 1.2.0-rc03 accompanist = 0.24.13-rc composeNavigation = 2.5.0 compose-destinations = 1.6.13-beta

also having the exact same issue

You don’t need to include compose navigation explicitly. I don’t know if that could be the issue, but you definitely shouldn’t 🙂

raamcosta commented 2 years ago

And you don’t need accompanist either. At least not accompanist navigation or accompanist material.

raamcosta commented 2 years ago

kotlin = "1.7.0" compose = 1.2.0-rc03 composeCompiler = "1.2.0" composeNavigation = 2.5.0 compose-destinations = 1.6.13-beta accompanist = 0.24.13-rc

also having the exact same issue

There is actually no version of compose destinations which is built with Kotlin 1.7. That said I thought that should work still 🤔

raamcosta commented 2 years ago

Can you try using same versions we have here?

https://github.com/raamcosta/compose-destinations/blob/main/buildSrc/src/main/java/Versions.kt

You should only need Kotlin, compose, compose compiler and compose destinations should be 1.6.13-beta (same you have now)

jmadaminov commented 2 years ago

I've tried with the same version numbers as in your repository. Namely compose = "1.2.0-rc03" composeCompiler = "1.2.0-rc02" kotlin = "1.6.21" composeDestinations = "1.6.13-beta"

It's still throwing the error. But as soon as I downgraded the destinations version to "1.5.4-beta" it started working as usual

raamcosta commented 2 years ago

I also don’t know but it seems related to the compose navigation version we use internally.

jmadaminov commented 2 years ago

I'll continue using above versions with 1.5.13-beta for now I guess 😄 thanx anyways

raamcosta commented 2 years ago

We inherit the good and also the bad with compose navigation I guess 😁

HLCaptain commented 2 years ago

I have noticed, that the sample project has the Crossfade dependency on version androidx.compose.animation:animation:1.0.1, while I used the exact same plugin version as the sample did and Crossfade dependency was on version androidx.compose.animation:animation:1.2.0-rc03. I tried to pinpoint the dependency which causes Crossfade to be version 1.2.0-rc03 and it only depended on io.github.raamcosta.compose-destinations:animations-core:1.6.14-beta. How come the sample project use an older version of this dependency, which actually works with the newer versions of Compose Destinations? How can I downgrade to it while sticking to the newer versions of Compose Destinations?

raamcosta commented 2 years ago

Gradle has a way to force a specific version of a dependency. I’m sure you can find it online. Atm I can’t help more than this 😅 It’s weird if my sample is using a different version of it 🤔 I did not specify anything like that.

HLCaptain commented 2 years ago

I did what you said, but with the same dependency, it still crashes. Haha. I still don't know, why the sample works while mine doesn't 😆 .

nrobi144 commented 1 year ago

Getting this issue on 1.7.23-beta 🤔

entrealist commented 1 year ago

Same issue here with 1.7.23-beta. Is there anything we can do about it?

Hi @HLCaptain, did you find out the way to fix the error?

raamcosta commented 1 year ago

Try updating it to 1.7.33-beta. This looks like some issue from official compose navigation which gets updated internally to the new stable version.