android 编写运行时版本不兼容

yc0p9oo0  于 2023-06-04  发布在  Android
关注(0)|答案(2)|浏览(364)

我试图在多模块项目中实现合成,我经常遇到以下错误:

androidx.compose.compiler.plugins.kotlin.IncompatibleComposeRuntimeVersionException: You are using an outdated version of Compose Runtime that is not compatible with the version of the Compose Compiler plugin you have installed. The compose compiler plugin you are using (version 1.0.3) expects a minimum runtime version of 1.0.0.  at androidx.compose.compiler.plugins.kotlin.VersionChecker.outdatedRuntimeWithUnknownVersionNumber(VersionChecker.kt:119)

我只有一个指定的版本(1.0.3)用于所有的Compose依赖项,我还尝试将compose编译器添加到root build.gradle:

dependencies {
      implementation "androidx.compose.compiler:compiler:1.0.3"
}

在根文件中,我还添加了compose的配置:

buildFeatures {
       compose true
 }
 composeOptions {
        kotlinCompilerExtensionVersion '1.0.3'
 }
 kotlinOptions {
        jvmTarget = '1.8'
 }

然后在module build.gradle中添加了compose dependencies(compose ui,material,ui toolign preview和uitooling),我还将gradle升级到最新的7.0.2,仍然出现相同的错误,我检查了gradle dependency tree no sign on 1.0.0 compiler anywhere,任何想法还有什么我可以尝试的,或者我做错了什么?

2w2cym1i

2w2cym1i1#

好吧,问题是我必须在根Gradle上包含activity-compose依赖项,这样它才能正常工作(如果我试图在每个模块中包含它,它就不起作用了)

r7s23pms

r7s23pms2#

implementation“androidx.activity:activity-compose:1.6.1”在app gradle中使用它。

相关问题