반응형
java.lang.IllegalStateException: ViewTreeLifecycleOwner not found from androidx.coordinatorlayout.widget.CoordinatorLayout{25a0d04 V.E...... ......ID 0,0-0,0 #7f090122 app:id/common_container}
at androidx.compose.ui.platform.WindowRecomposer_androidKt.createLifecycleAwareViewTreeRecomposer(WindowRecomposer.android.kt:244)
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:99)
at androidx.compose.ui.platform.WindowRecomposerPolicy.createAndInstallWindowRecomposer$ui_release(WindowRecomposer.android.kt:155)
at androidx.compose.ui.platform.WindowRecomposer_androidKt.getWindowRecomposer(WindowRecomposer.android.kt:230)
at androidx.compose.ui.platform.AbstractComposeView.resolveParentCompositionContext(ComposeView.android.kt:220)
at androidx.compose.ui.platform.AbstractComposeView.ensureCompositionCreated(ComposeView.android.kt:227)
at androidx.compose.ui.platform.AbstractComposeView.onAttachedToWindow(ComposeView.android.kt:259)
기존 프로젝트에 Compose 를 넣어보려고 커스텀 뷰를 AbstractComposeView
로 전환하고 기존 xml 에 넣고 빌드를 돌리니
위와 같은 에러가 발생했다.
ViewTreeLifecycleOwner
이 없다고 나오는데
LifeCycleOwner 를 쉽게 얻을 수 있도록 나온 새로운 API 이다.
xml 을 불러올 때 포함된 AbstractComposeView 가 사용할 context 를 가져올 때
ViewTreeLifecycleOwner 를 사용하고 있다.
androidx.appcompat:appcompat:1.3.0
ViewTreeLifecycleOwner 는 appCompat 1.3.0
부터 추가 되어있으니 버전을 올려주면 빌드가 잘된다.
반응형
'안드로이드' 카테고리의 다른 글
Android - MovableContentOf in Compose (0) | 2022.08.10 |
---|---|
Compose 1.1 정리 (0) | 2022.02.16 |
오픈소스 라이선스 만들기 (0) | 2021.02.23 |
Error ) NavigationExtensions - does not have a NavController set (0) | 2021.02.03 |
Dagger ( Hilt ) 2.31 - 변경된 ViewModel 주입 (0) | 2021.01.27 |