androidx.compose.runtime.ComposeRuntimeError: Compose Runtime internal error. Unexpected or incorrect use of the Compose internal runtime API (Cannot seek outside the current group (302-353)). Please report to Google or use https://goo.gle/compose-feedback
at androidx.compose.runtime.ComposerKt.composeRuntimeError(Composer.kt:4522)
at androidx.compose.runtime.SlotWriter.advanceBy(SlotTable.kt:3482)
at androidx.compose.runtime.ComposerImpl$realizeOperationLocation$2.invoke(Composer.kt:3553)
at androidx.compose.runtime.ComposerImpl$realizeOperationLocation$2.invoke(Composer.kt:3553)
at androidx.compose.runtime.CompositionImpl.applyChangesInLocked(Composition.kt:810)
at androidx.compose.runtime.CompositionImpl.applyChanges(Composition.kt:842)
at androidx.compose.runtime.Recomposer$runRecomposeAndApplyChanges$2$2.invoke(Recomposer.kt:592)
at androidx.compose.runtime.Recomposer$runRecomposeAndApplyChanges$2$2.invoke(Recomposer.kt:510)
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:947)
at android.view.Choreographer.doCallbacks(Choreographer.java:761)
at android.view.Choreographer.doFrame(Choreographer.java:693)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:935)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6825)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:860)
Suppressed: kotlinx.coroutines.DiagnosticCoroutineContextException: [androidx.compose.runtime.PausableMonotonicFrameClock@c10bbd2, androidx.compose.ui.platform.MotionDurationScaleImpl@2c624a3, StandaloneCoroutine{Cancelling}@69973a0, AndroidUiDispatcher@e512b59]
代码示例
class A() {
var first = true
var code = MutableLiveData("")
@Composable
fun Prepare() {
Fun1()
if (first) {
Fun2()
}
first = false
Fun3()
}
@Composable
open fun Fun1() {
//CODE 1
code.observeAsState("").value
}
@Composable
open fun Fun2() {
//CODE 2
code.observeAsState("").value
}
@Composable
fun Fun3() {
//CODE 3
code.observeAsState("").value
}
}
class B : A() {
@Composable
override fun Fun1() {
super.Fun1() //去掉即可
}
@Composable
override fun Fun2() {
super.Fun2()
}
}
现象: