意外的锚点值,在 Compose 应用程序发布构建中预期为负锚点
Unexpected anchor value, expected a negative anchor in Compose app release builds
我在我的项目中使用 Kotlin 1.6.21,compose 1.2.0-alpha08 和伴奏 0.24.7-alpha。当使用发布版本(使用和不使用 R8)构建项目时,我的应用程序在启动时立即崩溃,我一直无法找到解决方法。我包括了一个堆栈跟踪,它几乎不包含我的应用程序代码行。
java.lang.IllegalStateException: Compose Runtime internal error. Unexpected or incorrect use of the Compose internal runtime API (Unexpected anchor value, expected a negative anchor). Please report to Google or use https://goo.gle/compose-feedback
at androidx.compose.runtime.ComposerKt.composeRuntimeError(Composer.kt:4215)
at androidx.compose.runtime.SlotWriter.moveSlotGapTo(SlotTable.kt:3472)
at androidx.compose.runtime.SlotWriter.insertSlots(SlotTable.kt:2582)
at androidx.compose.runtime.SlotWriter.insertAux(SlotTable.kt:1366)
at androidx.compose.runtime.ComposerImpl.sourceInformation(Composer.kt:3067)
at androidx.compose.runtime.ComposerKt.sourceInformation(Composer.kt:1075)
at androidx.compose.material.ScaffoldKt.rememberScaffoldState(Unknown Source:8)
at com.nek12.test.ui.screens.home.HomeScreenKt.HomeScreen(HomeScreen.kt:54)
at com.nek12.test.ui.screens.destinations.HomeScreenDestination.Content(HomeScreenDestination.kt:26)
at com.ramcosta.composedestinations.animations.AnimatedNavHostEngine.CallComposable(AnimatedNavHostEngine.kt:256)
at com.ramcosta.composedestinations.animations.AnimatedNavHostEngine.access$CallComposable(AnimatedNavHostEngine.kt:57)
at com.ramcosta.composedestinations.animations.AnimatedNavHostEngine$addComposable.invoke(AnimatedNavHostEngine.kt:166)
at com.ramcosta.composedestinations.animations.AnimatedNavHostEngine$addComposable.invoke(AnimatedNavHostEngine.kt:165)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:135)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
at com.google.accompanist.navigation.animation.AnimatedNavHostKt$AnimatedNavHost.invoke(AnimatedNavHost.kt:212)
at com.google.accompanist.navigation.animation.AnimatedNavHostKt$AnimatedNavHost.invoke(AnimatedNavHost.kt:210)
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.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:228)
at androidx.compose.runtime.saveable.SaveableStateHolderImpl.SaveableStateProvider(SaveableStateHolder.kt:84)
at androidx.navigation.compose.NavBackStackEntryProviderKt.SaveableStateProvider(NavBackStackEntryProvider.kt:60)
at androidx.navigation.compose.NavBackStackEntryProviderKt.access$SaveableStateProvider(NavBackStackEntryProvider.kt:1)
at androidx.navigation.compose.NavBackStackEntryProviderKt$LocalOwnersProvider.invoke(NavBackStackEntryProvider.kt:52)
at androidx.navigation.compose.NavBackStackEntryProviderKt$LocalOwnersProvider.invoke(NavBackStackEntryProvider.kt:51)
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.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:228)
at androidx.navigation.compose.NavBackStackEntryProviderKt.LocalOwnersProvider(NavBackStackEntryProvider.kt:47)
at com.google.accompanist.navigation.animation.AnimatedNavHostKt$AnimatedNavHost.invoke(AnimatedNavHost.kt:210)
at com.google.accompanist.navigation.animation.AnimatedNavHostKt$AnimatedNavHost.invoke(AnimatedNavHost.kt:202)
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.invoke(AnimatedContent.kt:658)
at androidx.compose.animation.AnimatedContentKt$AnimatedContent.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)
E/AndroidRuntime: at androidx.compose.animation.AnimatedVisibilityKt.AnimatedEnterExitImpl(AnimatedVisibility.kt:937)
at androidx.compose.animation.AnimatedVisibilityKt.AnimatedVisibility(AnimatedVisibility.kt:606)
at androidx.compose.animation.AnimatedContentKt$AnimatedContent.invoke(AnimatedContent.kt:638)
at androidx.compose.animation.AnimatedContentKt$AnimatedContent.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:197)
at com.google.accompanist.navigation.animation.AnimatedNavHostKt.AnimatedNavHost(AnimatedNavHost.kt:91)
at com.ramcosta.composedestinations.animations.AnimatedNavHostEngine.NavHost(AnimatedNavHostEngine.kt:82)
at com.ramcosta.composedestinations.DestinationsNavHostKt.DestinationsNavHost(DestinationsNavHost.kt:60)
at com.nek12.test.ui.testNavigationKt$testNavigation.invoke(testNavigation.kt:29)
at com.nek12.test.ui.testNavigationKt$testNavigation.invoke(testNavigation.kt:28)
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.invoke(ModalBottomSheet.kt:330)
at androidx.compose.material.ModalBottomSheetKt$ModalBottomSheetLayout.invoke(ModalBottomSheet.kt:326)
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.foundation.layout.BoxWithConstraintsKt$BoxWithConstraints$measurables.invoke(BoxWithConstraints.kt:69)
at androidx.compose.foundation.layout.BoxWithConstraintsKt$BoxWithConstraints$measurables.invoke(BoxWithConstraints.kt:69)
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.ui.layout.LayoutNodeSubcompositionsState$subcompose.invoke(SubcomposeLayout.kt:753)
at androidx.compose.ui.layout.LayoutNodeSubcompositionsState$subcompose.invoke(SubcomposeLayout.kt:447)
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.runtime.ActualJvm_jvmKt.invokeComposable(ActualJvm.jvm.kt:74)
at androidx.compose.runtime.ComposerImpl$doCompose.invoke(Composer.kt:3164)
at androidx.compose.runtime.ComposerImpl$doCompose.invoke(Composer.kt:3154)
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:3154)
at androidx.compose.runtime.ComposerImpl.composeContent$runtime_release(Composer.kt:3091)
at androidx.compose.runtime.CompositionImpl.composeContent(Composition.kt:568)
at androidx.compose.runtime.Recomposer.composeInitial$runtime_release(Recomposer.kt:811)
at androidx.compose.runtime.ComposerImpl$CompositionContextImpl.composeInitial$runtime_release(Composer.kt:3683)
at androidx.compose.runtime.CompositionImpl.setContent(Composition.kt:503)
at androidx.compose.ui.layout.LayoutNodeSubcompositionsState.subcomposeInto(SubcomposeLayout.kt:467)
at androidx.compose.ui.layout.LayoutNodeSubcompositionsState.subcompose(SubcomposeLayout.kt:440)
E/AndroidRuntime: at androidx.compose.ui.layout.LayoutNodeSubcompositionsState.subcompose(SubcomposeLayout.kt:431)
at androidx.compose.ui.layout.LayoutNodeSubcompositionsState.subcompose(SubcomposeLayout.kt:420)
at androidx.compose.ui.layout.LayoutNodeSubcompositionsState$Scope.subcompose(SubcomposeLayout.kt:715)
at androidx.compose.foundation.layout.BoxWithConstraintsKt$BoxWithConstraints.invoke-0kLqBqw(BoxWithConstraints.kt:69)
at androidx.compose.foundation.layout.BoxWithConstraintsKt$BoxWithConstraints.invoke(BoxWithConstraints.kt:67)
at androidx.compose.ui.layout.LayoutNodeSubcompositionsState$createMeasurePolicy.measure-3p2s80s(SubcomposeLayout.kt:581)
at androidx.compose.ui.node.InnerPlaceable.measure-BRTryo0(InnerPlaceable.kt:44)
at androidx.compose.ui.node.LayoutNode$performMeasure.invoke(LayoutNode.kt:1388)
at androidx.compose.ui.node.LayoutNode$performMeasure.invoke(LayoutNode.kt:1387)
at androidx.compose.runtime.snapshots.Snapshot$Companion.observe(Snapshot.kt:2063)
at androidx.compose.runtime.snapshots.SnapshotStateObserver.observeReads(SnapshotStateObserver.kt:112)
at androidx.compose.ui.node.OwnerSnapshotObserver.observeReads$ui_release(OwnerSnapshotObserver.kt:78)
at androidx.compose.ui.node.OwnerSnapshotObserver.observeMeasureSnapshotReads$ui_release(OwnerSnapshotObserver.kt:66)
at androidx.compose.ui.node.LayoutNode.performMeasure-BRTryo0$ui_release(LayoutNode.kt:1387)
at androidx.compose.ui.node.OuterMeasurablePlaceable.remeasure-BRTryo0(OuterMeasurablePlaceable.kt:94)
at androidx.compose.ui.node.OuterMeasurablePlaceable.measure-BRTryo0(OuterMeasurablePlaceable.kt:75)
at androidx.compose.ui.node.LayoutNode.measure-BRTryo0(LayoutNode.kt:1331)
at androidx.compose.ui.layout.RootMeasurePolicy.measure-3p2s80s(RootMeasurePolicy.kt:38)
at androidx.compose.ui.node.InnerPlaceable.measure-BRTryo0(InnerPlaceable.kt:44)
at androidx.compose.ui.node.LayoutNode$performMeasure.invoke(LayoutNode.kt:1388)
at androidx.compose.ui.node.LayoutNode$performMeasure.invoke(LayoutNode.kt:1387)
at androidx.compose.runtime.snapshots.Snapshot$Companion.observe(Snapshot.kt:2063)
at androidx.compose.runtime.snapshots.SnapshotStateObserver.observeReads(SnapshotStateObserver.kt:112)
at androidx.compose.ui.node.OwnerSnapshotObserver.observeReads$ui_release(OwnerSnapshotObserver.kt:78)
at androidx.compose.ui.node.OwnerSnapshotObserver.observeMeasureSnapshotReads$ui_release(OwnerSnapshotObserver.kt:66)
at androidx.compose.ui.node.LayoutNode.performMeasure-BRTryo0$ui_release(LayoutNode.kt:1387)
at androidx.compose.ui.node.OuterMeasurablePlaceable.remeasure-BRTryo0(OuterMeasurablePlaceable.kt:94)
at androidx.compose.ui.node.LayoutNode.remeasure-_Sx5XlM$ui_release(LayoutNode.kt:1341)
at androidx.compose.ui.node.MeasureAndLayoutDelegate.doRemeasure-sdFAvZA(MeasureAndLayoutDelegate.kt:185)
at androidx.compose.ui.node.MeasureAndLayoutDelegate.remeasureAndRelayoutIfNeeded(MeasureAndLayoutDelegate.kt:274)
at androidx.compose.ui.node.MeasureAndLayoutDelegate.access$remeasureAndRelayoutIfNeeded(MeasureAndLayoutDelegate.kt:38)
at androidx.compose.ui.node.MeasureAndLayoutDelegate.measureAndLayout(MeasureAndLayoutDelegate.kt:208)
at androidx.compose.ui.platform.AndroidComposeView.onMeasure(AndroidComposeView.android.kt:789)
at android.view.View.measure(View.java:25774)
at androidx.compose.ui.platform.AbstractComposeView.internalOnMeasure$ui_release(ComposeView.android.kt:298)
at androidx.compose.ui.platform.AbstractComposeView.onMeasure(ComposeView.android.kt:285)
at android.view.View.measure(View.java:25774)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6980)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
at android.view.View.measure(View.java:25774)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6980)
at com.android.internal.widget.ActionBarOverlayLayout.onMeasure(ActionBarOverlayLayout.java:463)
at android.view.View.measure(View.java:25774)
E/AndroidRuntime: at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6980)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
at com.android.internal.policy.DecorView.onMeasure(DecorView.java:761)
at android.view.View.measure(View.java:25774)
at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:3628)
at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:2424)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2694)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:2143)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:8670)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1037)
at android.view.Choreographer.doCallbacks(Choreographer.java:845)
at android.view.Choreographer.doFrame(Choreographer.java:780)
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:550)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
我在 google 的问题跟踪器上对 this bug 发表了评论,但它不仅在 3 个多月内没有得到修复,而且看起来也非常相似,但并不完全相同我的问题是因为我的堆栈跟踪中没有任何内联...
我该如何解决这个问题,为什么在我之前没有人提交错误报告?在修复之前,我的应用程序发布版本实际上无法使用。
UPD:更多细节:
这里是 rememberScaffoldState()
的调用点
@Composable
@Destination(start = true)
fun HomeScreen(
navigator: DestinationsNavigator,
) = MVIComposable(getViewModel<HomeViewModel>()) { state ->
val scaffoldState = rememberScaffoldState()
val context = LocalContext.current
这是我的导航可组合项的内容
val navHostEngine = rememberAnimatedNavHostEngine(
//TODO: Customize
rootDefaultAnimations = RootNavGraphDefaultAnimations.ACCOMPANIST_FADING,
)
val navController = rememberAnimatedNavController()
val bottomSheetNavigator = rememberBottomSheetNavigator()
navController.navigatorProvider += bottomSheetNavigator
//Wrap entire app in a bottom sheet in order to navigate to bottom sheets with destinations
RBottomSheet(bottomSheetNavigator) {
DestinationsNavHost(navGraph = NavGraphs.root, engine = navHostEngine, navController = navController)
}
长话短说:
不要将内联函数与 compose 一起使用。至少在这个问题得到解决之前不会
我通过检查我的依赖关系解决了这个问题。其中一个依赖项在组合中的某处传递地使用了内联函数,并产生了错误。我不得不删除依赖项。显然这确实是 google 问题跟踪器中的内联问题。
我在我的项目中使用 Kotlin 1.6.21,compose 1.2.0-alpha08 和伴奏 0.24.7-alpha。当使用发布版本(使用和不使用 R8)构建项目时,我的应用程序在启动时立即崩溃,我一直无法找到解决方法。我包括了一个堆栈跟踪,它几乎不包含我的应用程序代码行。
java.lang.IllegalStateException: Compose Runtime internal error. Unexpected or incorrect use of the Compose internal runtime API (Unexpected anchor value, expected a negative anchor). Please report to Google or use https://goo.gle/compose-feedback
at androidx.compose.runtime.ComposerKt.composeRuntimeError(Composer.kt:4215)
at androidx.compose.runtime.SlotWriter.moveSlotGapTo(SlotTable.kt:3472)
at androidx.compose.runtime.SlotWriter.insertSlots(SlotTable.kt:2582)
at androidx.compose.runtime.SlotWriter.insertAux(SlotTable.kt:1366)
at androidx.compose.runtime.ComposerImpl.sourceInformation(Composer.kt:3067)
at androidx.compose.runtime.ComposerKt.sourceInformation(Composer.kt:1075)
at androidx.compose.material.ScaffoldKt.rememberScaffoldState(Unknown Source:8)
at com.nek12.test.ui.screens.home.HomeScreenKt.HomeScreen(HomeScreen.kt:54)
at com.nek12.test.ui.screens.destinations.HomeScreenDestination.Content(HomeScreenDestination.kt:26)
at com.ramcosta.composedestinations.animations.AnimatedNavHostEngine.CallComposable(AnimatedNavHostEngine.kt:256)
at com.ramcosta.composedestinations.animations.AnimatedNavHostEngine.access$CallComposable(AnimatedNavHostEngine.kt:57)
at com.ramcosta.composedestinations.animations.AnimatedNavHostEngine$addComposable.invoke(AnimatedNavHostEngine.kt:166)
at com.ramcosta.composedestinations.animations.AnimatedNavHostEngine$addComposable.invoke(AnimatedNavHostEngine.kt:165)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:135)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
at com.google.accompanist.navigation.animation.AnimatedNavHostKt$AnimatedNavHost.invoke(AnimatedNavHost.kt:212)
at com.google.accompanist.navigation.animation.AnimatedNavHostKt$AnimatedNavHost.invoke(AnimatedNavHost.kt:210)
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.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:228)
at androidx.compose.runtime.saveable.SaveableStateHolderImpl.SaveableStateProvider(SaveableStateHolder.kt:84)
at androidx.navigation.compose.NavBackStackEntryProviderKt.SaveableStateProvider(NavBackStackEntryProvider.kt:60)
at androidx.navigation.compose.NavBackStackEntryProviderKt.access$SaveableStateProvider(NavBackStackEntryProvider.kt:1)
at androidx.navigation.compose.NavBackStackEntryProviderKt$LocalOwnersProvider.invoke(NavBackStackEntryProvider.kt:52)
at androidx.navigation.compose.NavBackStackEntryProviderKt$LocalOwnersProvider.invoke(NavBackStackEntryProvider.kt:51)
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.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:228)
at androidx.navigation.compose.NavBackStackEntryProviderKt.LocalOwnersProvider(NavBackStackEntryProvider.kt:47)
at com.google.accompanist.navigation.animation.AnimatedNavHostKt$AnimatedNavHost.invoke(AnimatedNavHost.kt:210)
at com.google.accompanist.navigation.animation.AnimatedNavHostKt$AnimatedNavHost.invoke(AnimatedNavHost.kt:202)
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.invoke(AnimatedContent.kt:658)
at androidx.compose.animation.AnimatedContentKt$AnimatedContent.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)
E/AndroidRuntime: at androidx.compose.animation.AnimatedVisibilityKt.AnimatedEnterExitImpl(AnimatedVisibility.kt:937)
at androidx.compose.animation.AnimatedVisibilityKt.AnimatedVisibility(AnimatedVisibility.kt:606)
at androidx.compose.animation.AnimatedContentKt$AnimatedContent.invoke(AnimatedContent.kt:638)
at androidx.compose.animation.AnimatedContentKt$AnimatedContent.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:197)
at com.google.accompanist.navigation.animation.AnimatedNavHostKt.AnimatedNavHost(AnimatedNavHost.kt:91)
at com.ramcosta.composedestinations.animations.AnimatedNavHostEngine.NavHost(AnimatedNavHostEngine.kt:82)
at com.ramcosta.composedestinations.DestinationsNavHostKt.DestinationsNavHost(DestinationsNavHost.kt:60)
at com.nek12.test.ui.testNavigationKt$testNavigation.invoke(testNavigation.kt:29)
at com.nek12.test.ui.testNavigationKt$testNavigation.invoke(testNavigation.kt:28)
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.invoke(ModalBottomSheet.kt:330)
at androidx.compose.material.ModalBottomSheetKt$ModalBottomSheetLayout.invoke(ModalBottomSheet.kt:326)
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.foundation.layout.BoxWithConstraintsKt$BoxWithConstraints$measurables.invoke(BoxWithConstraints.kt:69)
at androidx.compose.foundation.layout.BoxWithConstraintsKt$BoxWithConstraints$measurables.invoke(BoxWithConstraints.kt:69)
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.ui.layout.LayoutNodeSubcompositionsState$subcompose.invoke(SubcomposeLayout.kt:753)
at androidx.compose.ui.layout.LayoutNodeSubcompositionsState$subcompose.invoke(SubcomposeLayout.kt:447)
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.runtime.ActualJvm_jvmKt.invokeComposable(ActualJvm.jvm.kt:74)
at androidx.compose.runtime.ComposerImpl$doCompose.invoke(Composer.kt:3164)
at androidx.compose.runtime.ComposerImpl$doCompose.invoke(Composer.kt:3154)
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:3154)
at androidx.compose.runtime.ComposerImpl.composeContent$runtime_release(Composer.kt:3091)
at androidx.compose.runtime.CompositionImpl.composeContent(Composition.kt:568)
at androidx.compose.runtime.Recomposer.composeInitial$runtime_release(Recomposer.kt:811)
at androidx.compose.runtime.ComposerImpl$CompositionContextImpl.composeInitial$runtime_release(Composer.kt:3683)
at androidx.compose.runtime.CompositionImpl.setContent(Composition.kt:503)
at androidx.compose.ui.layout.LayoutNodeSubcompositionsState.subcomposeInto(SubcomposeLayout.kt:467)
at androidx.compose.ui.layout.LayoutNodeSubcompositionsState.subcompose(SubcomposeLayout.kt:440)
E/AndroidRuntime: at androidx.compose.ui.layout.LayoutNodeSubcompositionsState.subcompose(SubcomposeLayout.kt:431)
at androidx.compose.ui.layout.LayoutNodeSubcompositionsState.subcompose(SubcomposeLayout.kt:420)
at androidx.compose.ui.layout.LayoutNodeSubcompositionsState$Scope.subcompose(SubcomposeLayout.kt:715)
at androidx.compose.foundation.layout.BoxWithConstraintsKt$BoxWithConstraints.invoke-0kLqBqw(BoxWithConstraints.kt:69)
at androidx.compose.foundation.layout.BoxWithConstraintsKt$BoxWithConstraints.invoke(BoxWithConstraints.kt:67)
at androidx.compose.ui.layout.LayoutNodeSubcompositionsState$createMeasurePolicy.measure-3p2s80s(SubcomposeLayout.kt:581)
at androidx.compose.ui.node.InnerPlaceable.measure-BRTryo0(InnerPlaceable.kt:44)
at androidx.compose.ui.node.LayoutNode$performMeasure.invoke(LayoutNode.kt:1388)
at androidx.compose.ui.node.LayoutNode$performMeasure.invoke(LayoutNode.kt:1387)
at androidx.compose.runtime.snapshots.Snapshot$Companion.observe(Snapshot.kt:2063)
at androidx.compose.runtime.snapshots.SnapshotStateObserver.observeReads(SnapshotStateObserver.kt:112)
at androidx.compose.ui.node.OwnerSnapshotObserver.observeReads$ui_release(OwnerSnapshotObserver.kt:78)
at androidx.compose.ui.node.OwnerSnapshotObserver.observeMeasureSnapshotReads$ui_release(OwnerSnapshotObserver.kt:66)
at androidx.compose.ui.node.LayoutNode.performMeasure-BRTryo0$ui_release(LayoutNode.kt:1387)
at androidx.compose.ui.node.OuterMeasurablePlaceable.remeasure-BRTryo0(OuterMeasurablePlaceable.kt:94)
at androidx.compose.ui.node.OuterMeasurablePlaceable.measure-BRTryo0(OuterMeasurablePlaceable.kt:75)
at androidx.compose.ui.node.LayoutNode.measure-BRTryo0(LayoutNode.kt:1331)
at androidx.compose.ui.layout.RootMeasurePolicy.measure-3p2s80s(RootMeasurePolicy.kt:38)
at androidx.compose.ui.node.InnerPlaceable.measure-BRTryo0(InnerPlaceable.kt:44)
at androidx.compose.ui.node.LayoutNode$performMeasure.invoke(LayoutNode.kt:1388)
at androidx.compose.ui.node.LayoutNode$performMeasure.invoke(LayoutNode.kt:1387)
at androidx.compose.runtime.snapshots.Snapshot$Companion.observe(Snapshot.kt:2063)
at androidx.compose.runtime.snapshots.SnapshotStateObserver.observeReads(SnapshotStateObserver.kt:112)
at androidx.compose.ui.node.OwnerSnapshotObserver.observeReads$ui_release(OwnerSnapshotObserver.kt:78)
at androidx.compose.ui.node.OwnerSnapshotObserver.observeMeasureSnapshotReads$ui_release(OwnerSnapshotObserver.kt:66)
at androidx.compose.ui.node.LayoutNode.performMeasure-BRTryo0$ui_release(LayoutNode.kt:1387)
at androidx.compose.ui.node.OuterMeasurablePlaceable.remeasure-BRTryo0(OuterMeasurablePlaceable.kt:94)
at androidx.compose.ui.node.LayoutNode.remeasure-_Sx5XlM$ui_release(LayoutNode.kt:1341)
at androidx.compose.ui.node.MeasureAndLayoutDelegate.doRemeasure-sdFAvZA(MeasureAndLayoutDelegate.kt:185)
at androidx.compose.ui.node.MeasureAndLayoutDelegate.remeasureAndRelayoutIfNeeded(MeasureAndLayoutDelegate.kt:274)
at androidx.compose.ui.node.MeasureAndLayoutDelegate.access$remeasureAndRelayoutIfNeeded(MeasureAndLayoutDelegate.kt:38)
at androidx.compose.ui.node.MeasureAndLayoutDelegate.measureAndLayout(MeasureAndLayoutDelegate.kt:208)
at androidx.compose.ui.platform.AndroidComposeView.onMeasure(AndroidComposeView.android.kt:789)
at android.view.View.measure(View.java:25774)
at androidx.compose.ui.platform.AbstractComposeView.internalOnMeasure$ui_release(ComposeView.android.kt:298)
at androidx.compose.ui.platform.AbstractComposeView.onMeasure(ComposeView.android.kt:285)
at android.view.View.measure(View.java:25774)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6980)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
at android.view.View.measure(View.java:25774)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6980)
at com.android.internal.widget.ActionBarOverlayLayout.onMeasure(ActionBarOverlayLayout.java:463)
at android.view.View.measure(View.java:25774)
E/AndroidRuntime: at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6980)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
at com.android.internal.policy.DecorView.onMeasure(DecorView.java:761)
at android.view.View.measure(View.java:25774)
at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:3628)
at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:2424)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2694)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:2143)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:8670)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1037)
at android.view.Choreographer.doCallbacks(Choreographer.java:845)
at android.view.Choreographer.doFrame(Choreographer.java:780)
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:550)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
我在 google 的问题跟踪器上对 this bug 发表了评论,但它不仅在 3 个多月内没有得到修复,而且看起来也非常相似,但并不完全相同我的问题是因为我的堆栈跟踪中没有任何内联...
我该如何解决这个问题,为什么在我之前没有人提交错误报告?在修复之前,我的应用程序发布版本实际上无法使用。
UPD:更多细节: 这里是 rememberScaffoldState()
的调用点@Composable
@Destination(start = true)
fun HomeScreen(
navigator: DestinationsNavigator,
) = MVIComposable(getViewModel<HomeViewModel>()) { state ->
val scaffoldState = rememberScaffoldState()
val context = LocalContext.current
这是我的导航可组合项的内容
val navHostEngine = rememberAnimatedNavHostEngine(
//TODO: Customize
rootDefaultAnimations = RootNavGraphDefaultAnimations.ACCOMPANIST_FADING,
)
val navController = rememberAnimatedNavController()
val bottomSheetNavigator = rememberBottomSheetNavigator()
navController.navigatorProvider += bottomSheetNavigator
//Wrap entire app in a bottom sheet in order to navigate to bottom sheets with destinations
RBottomSheet(bottomSheetNavigator) {
DestinationsNavHost(navGraph = NavGraphs.root, engine = navHostEngine, navController = navController)
}
长话短说: 不要将内联函数与 compose 一起使用。至少在这个问题得到解决之前不会
我通过检查我的依赖关系解决了这个问题。其中一个依赖项在组合中的某处传递地使用了内联函数,并产生了错误。我不得不删除依赖项。显然这确实是 google 问题跟踪器中的内联问题。