I got this error when I upgrade my compose version from 1.0.0-beta01
to 1.0.0-beta02
(and also need to upgrade from kotlin-gradle-plugin from 1.4.30
to 1.4.31
.)
java.lang.IllegalStateException: ViewTreeLifecycleOwner not set for this ComposeView.
If you are adding this ComposeView to an AppCompatActivity, make sure you are using AppCompat version 1.3+.
If you are adding this ComposeView to a Fragment, make sure you are using Fragment version 1.3+.
For other cases, manually set owners on this view by using `ViewTreeLifecycleOwner.set()` and `ViewTreeSavedStateRegistryOwner.set()`.
buildscript {
ext {
compose_version = '1.0.0-beta02'
}
repositories {
google()
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:7.0.0-alpha08"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.31"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
My dependencies are as below
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.3.0'
implementation "androidx.compose.ui:ui:$compose_version"
implementation "androidx.compose.material:material:$compose_version"
implementation "androidx.compose.ui:ui-tooling:$compose_version"
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.0'
implementation 'androidx.activity:activity-compose:1.3.0-alpha03'
implementation 'dev.chrisbanes.accompanist:accompanist-insets:0.6.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
I did try to upgrade my androidx.appcompat:appcompat
dependencies from 1.2.0 to 1.3.0, it will error stating Could not find androidx.appcompat:appcompat:1.3.0.
.
How can I resolve it?