Jetpack Compose – Problem with BottomSheetDialogFragment and ViewTreeLifecycleOwner

After updating the Jetpack Compose library to beta01, I’m not able to show DialogFragment or BottomSheetDialogFragment.
Looks like ViewTreeLifecycleOwner cannot be found in my activity anymore. Also, I tried a couple of possible solutions but there are not any success.

The view in fragment is inflated with:

 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 {...}

and dialog fragment is showing with:

DialogFragmentExample.newInstance().show(supportFragmentManager, null)

Does anyone have a similar problem? Please, any suggestion would be welcome.

Stacktracke:

java.lang.IllegalStateException: ViewTreeLifecycleOwner not found from [email protected][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)

Source: Android Questions

LEAVE A COMMENT