gpt4 book ai didi

android - 从 DecorView@2da7146[MyActivity] 找不到 ViewTreeLifecycleOwner

转载 作者:行者123 更新时间:2023-12-03 13:25:36 27 4
gpt4 key购买 nike

从 compose alpha-11 更新后至alpha-12 (或 beta-01 )每当我打开具有撰写 View 的 Activity 或 fragment 时,我都会遇到此崩溃。
我正在使用 AppCompatActivity实现LifecycleOwner ,所以这非常奇怪。

    java.lang.IllegalStateException: ViewTreeLifecycleOwner not found from DecorView@2da7146[MyActivity]
at androidx.compose.ui.platform.WindowRecomposer_androidKt.createLifecycleAwareViewTreeRecomposer(WindowRecomposer.android.kt:214)
at androidx.compose.ui.platform.WindowRecomposer_androidKt.access$createLifecycleAwareViewTreeRecomposer(WindowRecomposer.android.kt:1)
at androidx.compose.ui.platform.WindowRecomposerFactory$Companion$LifecycleAware$1.createRecomposer(WindowRecomposer.android.kt:98)
at androidx.compose.ui.platform.WindowRecomposerPolicy.createAndInstallWindowRecomposer$ui_release(WindowRecomposer.android.kt:151)
at androidx.compose.ui.platform.WindowRecomposer_androidKt.getWindowRecomposer(WindowRecomposer.android.kt:199)
at androidx.compose.ui.platform.AbstractComposeView.ensureCompositionCreated(ComposeView.android.kt:176)
at androidx.compose.ui.platform.AbstractComposeView.onAttachedToWindow(ComposeView.android.kt:207)
at android.view.View.dispatchAttachedToWindow(View.java:20014)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3589)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3596)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3596)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3596)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3596)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3596)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2223)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1888)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:8511)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:949)
at android.view.Choreographer.doCallbacks(Choreographer.java:761)
at android.view.Choreographer.doFrame(Choreographer.java:696)
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:214)
at android.app.ActivityThread.main(ActivityThread.java:7050)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:965)
我的代码看起来很简单:
    class MyActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

setContent {
MaterialTheme {
Text(text = "compose")
}
}
}
}
更新
显然你需要使用 androidx.appcompat:appcompat:1.3.0-beta01

最佳答案

尝试更新 AppCompat 的依赖关系至rc01版本。
这为我解决了这个问题。implementation 'androidx.appcompat:appcompat:1.3.0-rc01'

关于android - 从 DecorView@2da7146[MyActivity] 找不到 ViewTreeLifecycleOwner,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66382502/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com