将英文翻译成中文:
有人遇到类似的问题吗?请问有什么建议吗?
堆栈跟踪:
将Jetpack Compose库更新到beta01
后,我无法显示DialogFragment或BottomSheetDialogFragment。
看起来我的活动中找不到ViewTreeLifecycleOwner
。此外,我尝试了一些可能的{{link1:解决方案}},但没有任何成功。
片段中的视图是通过以下方式膨胀的:
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
return inflater.inflate(
R.layout.fragment_full_screen_layout, container, false
).apply {
findViewById<ComposeView>(R.id.compose_view).setContent {...}
对话框片段正在显示:
DialogFragmentExample.newInstance().show(supportFragmentManager, null)
有人遇到类似的问题吗?请问有什么建议吗?
堆栈跟踪:
java.lang.IllegalStateException: ViewTreeLifecycleOwner not found from DecorView@409dd5d[MainActivity]
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:177)
at androidx.compose.ui.platform.AbstractComposeView.onAttachedToWindow(ComposeView.android.kt:222)