我使用的是最新的Android Studio,将compose_version
设置为1.0.5
时,我可以很好地构建和运行我的应用。但是,我想使用最新的稳定合成版本1.1.1
。
我尝试简单地更新项目build.gradle
,使其包含指向所需compose版本和相应兼容Kotlin版本的以下内容。这些值在应用的build.gradle
中引用。
buildscript {
ext {
compose_version = '1.1.1'
kotlin_version = '1.6.10'
}
在Android Studio中,我会转到工具〉Kotlin〉配置Kotlin插件更新,然后下载最新的Kotlin插件(抢先体验)。
如果我打开“工具”〉“Kotlin”〉“Kotlin REPL”,我会看到Welcome to Kotlin version 1.7.0-RC2-release-258 (JRE 11.0.12+0-b1504.28-7817840)
。
现在,我尝试重建项目。
我得到错误:This version (1.1.1) of the Compose Compiler requires Kotlin version 1.6.10 but you appear to be using Kotlin version 1.5.31 which is not known to be compatible. Please fix your configuration (or suppressKotlinVersionCompatibilityCheck but don't say I didn't warn you!).
我不希望suppressKotlinVersionCompatibilityCheck
给出警告,但我甚至尝试了该选项,并得到其他构建错误。
为什么要使用Kotlin1.5.31版?更新Kotlin插件是否应该让Android Studio切换到更新的Kotlin版本(如Kotlin REPL消息所示)?如何才能使Kotlin 1.6.10版在使用时不再出现错误?
6条答案
按热度按时间f1tvaqid1#
Compose使用
buildscript
块中定义的Kotlin编译器:如果在
settings.gradle
或build.gradle
中使用plugins
块:7kjnsjlb2#
使用Compose
1.1.1.
和Kotlin1.7.0
时出现相同的错误。任务:应用程序:编译调试Kotlin失败e:此版本(1.1.1)的Compose Compiler需要Kotlin版本1.6.10,但您使用的Kotlin版本1.7.0不兼容。请修正您的配置(或
suppressKotlinVersionCompatibilityCheck
,但不要说我没有警告过您!)。更改了我的**build.gradle(应用模块)**中的以下块
这是我在build.gradle(项目)中的插件块:
这个Android开发者页面帮助选择兼容的版本:-
Compose to Kotlin Compatibility Map
不要忘记同步和重建。
s6fujrry3#
用这个帮我。
build.gradle (:app)
btxsgosb4#
和build.gradle(模块)
8yoxcaq75#
有3件事你需要确保是在同步(兼容其他)的Kotlin正常工作。
1)build.gradle中构建脚本的compose_ui_version =“1.2.1”(项目)
2)插件“org.jetbrains.kotlin.android”版本“1.7.10”在build.gradle中(项目)
3)kotlinCompilerExtensionVersion“1.3.1”在构成中构建.gradle(应用程序)中的选项
要获取compose编译器的最新版本及其相应的Kotlin版本,请查看此处。
ecr0jaav6#
对我来说,我必须编辑的是找到build graddle(项目):
1.首先加载compose_version以查看最新的稳定compose_version。