【发布时间】:2022-07-28 05:56:10
【问题描述】:
我正在使用最新的 Android Studio,并且我能够将 compose_version 设置为 1.0.5 来构建和运行我的应用程序。但是,我想使用最新的稳定 compose 版本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,但我什至尝试了该选项并得到其他构建错误。
为什么要使用 Kotlin 版本 1.5.31?更新 Kotlin 插件是否应该让 Android Studio 切换到更新的 Kotlin 版本(如 Kotlin REPL 消息所建议的那样)?我怎样才能使它使用 Kotlin 1.6.10 并且我停止收到错误?
【问题讨论】:
-
运行
./gradlew app:dependencies以查看 1.5.31 依赖项来自何处。 this guide 也有帮助 - 寻找resolutionStrategy -
检查
buildscript依赖classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:x.x.xx"
标签: android-studio kotlin android-jetpack-compose