raamcosta / compose-destinations

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

Crash in multi module setup #609

Closed brueggenthies-ams closed 2 months ago

brueggenthies-ams commented 2 months ago

Hey,

I am having trouble using compose-destinations in a multi module project.

Setup I don't want to use nested NavGraphs, therefore i define the NavGraph in the app module and include the generated destinations from the feature modules.

My Main NavGraph in the app module

@NavHostGraph
annotation class MainGraph {

    @ExternalModuleDestinations<FeatureonboardingModuleDestinations>
    companion object Includes
}

Destination in feature module

@Destination<ExternalModuleGraph>
@Composable
internal fun AcceptTermsOfServiceScreen() {
    ...
}

Crash When i try to navigate to the destination from the feature module, i get the following crash:

Process: com.wago.homeapp.dev, PID: 14997
java.lang.AbstractMethodError: abstract method "void com.ramcosta.composedestinations.spec.TypedDestinationSpec.Content(com.ramcosta.composedestinations.scope.DestinationScope, androidx.compose.runtime.Composer, int)"
at com.ramcosta.composedestinations.spec.DestinationStyleKt.CallComposable(DestinationStyle.kt:259)
at com.ramcosta.composedestinations.spec.DestinationStyleKt.access$CallComposable(DestinationStyle.kt:1)
at com.ramcosta.composedestinations.spec.DestinationStyle$Default$addComposable$1.invoke(DestinationStyle.kt:61)
at com.ramcosta.composedestinations.spec.DestinationStyle$Default$addComposable$1.invoke(DestinationStyle.kt:60)
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$22$1.invoke(NavHost.kt:483)
at androidx.navigation.compose.NavHostKt$NavHost$22$1.invoke(NavHost.kt:481)
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:250)
at androidx.compose.runtime.saveable.SaveableStateHolderImpl.SaveableStateProvider(SaveableStateHolder.kt:84)
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:229)
at androidx.navigation.compose.NavBackStackEntryProviderKt.LocalOwnersProvider(NavBackStackEntryProvider.kt:47)
at androidx.navigation.compose.NavHostKt$NavHost$22.invoke(NavHost.kt:481)
at androidx.navigation.compose.NavHostKt$NavHost$22.invoke(NavHost.kt:464)
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:755)
at androidx.compose.animation.AnimatedContentKt$AnimatedContent$6$1$5.invoke(AnimatedContent.kt:744)
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:819)
at androidx.compose.animation.AnimatedContentKt$AnimatedContent$6$1.invoke(AnimatedContent.kt:726)
at androidx.compose.animation.AnimatedContentKt$AnimatedContent$6$1.invoke(AnimatedContent.kt:709)
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:768)
at androidx.navigation.compose.NavHostKt.NavHost(NavHost.kt:441)
at androidx.navigation.compose.NavHostKt$NavHost$24.invoke(Unknown Source:29)
at androidx.navigation.compose.NavHostKt$NavHost$24.invoke(Unknown Source:10)
at androidx.compose.runtime.RecomposeScopeImpl.compose(RecomposeScopeImpl.kt:192)
2024-04-12 18:38:05.019 14997-14997 AndroidRuntime          com.wago.homeapp.dev                 E      at androidx.compose.runtime.ComposerImpl.recomposeToGroupEnd(Composer.kt:2761)
at androidx.compose.runtime.ComposerImpl.skipCurrentGroup(Composer.kt:3052)
at androidx.compose.runtime.ComposerImpl.doCompose(Composer.kt:3543)
at androidx.compose.runtime.ComposerImpl.recompose$runtime_release(Composer.kt:3488)
at androidx.compose.runtime.CompositionImpl.recompose(Composition.kt:948)
at androidx.compose.runtime.Recomposer.performRecompose(Recomposer.kt:1196)
at androidx.compose.runtime.Recomposer.access$performRecompose(Recomposer.kt:130)
at androidx.compose.runtime.Recomposer$runRecomposeAndApplyChanges$2$1.invoke(Recomposer.kt:607)
at androidx.compose.runtime.Recomposer$runRecomposeAndApplyChanges$2$1.invoke(Recomposer.kt:576)
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:1404)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1415)
at android.view.Choreographer.doCallbacks(Choreographer.java:1015)
at android.view.Choreographer.doFrame(Choreographer.java:941)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1389)
at android.os.Handler.handleCallback(Handler.java:959)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loopOnce(Looper.java:232)
at android.os.Looper.loop(Looper.java:317)
at android.app.ActivityThread.main(ActivityThread.java:8592)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:580)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:878)

Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [androidx.compose.runtime.PausableMonotonicFrameClock@19e2e81, androidx.compose.ui.platform.MotionDurationScaleImpl@b4b4b26, StandaloneCoroutine{Cancelling}@558c367, AndroidUiDispatcher@afec514]

Is there anything done wrong? If necessary, i can try to send in a sample project. However the current project is for a customer, and i therefore cannot simply share the project code.

Thanks in advance! :)

brueggenthies-ams commented 2 months ago

Forgot some Version information:

Compose Destinations Version: 2.1.0-beta01 Compose Version: 2024.04.00 BOM

raamcosta commented 2 months ago

A sample project would indeed help, I'm not able to reproduce this and I don't see what could be the root cause without it 🤔

brueggenthies-ams commented 2 months ago

@raamcosta i just created a sample project to reproduce the error, and was not able to do so... I compared the two and noticed, that the kotlin-android plugin was not applied in my project :D I guess that compose was therefore not able to transform the composable functions properly. Interesting that there were no signs before that runtime crash... Anyways, no issue in compose destinations as far as i can tell. Will close this issue.