gpt4 book ai didi

android - 如果您将此 ComposeView 添加到 AppCompatActivity,请确保您使用的是 AppCompat 版本 1.3+

转载 作者:行者123 更新时间:2023-12-03 15:41:11 40 4
gpt4 key购买 nike

当我从 1.0.0-beta01 升级我的 compose 版本时出现此错误至1.0.0-beta02(还需要从 kotlin-gradle-plugin 从 1.4.30 升级到 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
}
}
我的依赖项如下
    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'
我确实尝试升级我的 androidx.appcompat:appcompat从 1.2.0 到 1.3.0 的依赖关系,它会报错 Could not find androidx.appcompat:appcompat:1.3.0. .
我该如何解决?

最佳答案

此时,最新的 AppCompat 版本是 AppCompat 1.3.0-beta01 :

implementation 'androidx.appcompat:appcompat:1.3.0-beta01'
目前还没有稳定版本的 AppCompat 支持 Compose 所需的要求。

关于android - 如果您将此 ComposeView 添加到 AppCompatActivity,请确保您使用的是 AppCompat 版本 1.3+,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66610224/

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