gradle 我仍然得到“模块是用不兼容的Kotlin版本编译的”错误

1aaf6o9v  于 12个月前  发布在  Kotlin
关注(0)|答案(1)|浏览(222)

我认为I fixed my build通过添加ext.kotlin_version = '1.8.0'到我的Android应用程序中的build.gradle:

buildscript {
    ext.kotlin_version = '1.8.0'
    repositories {
        google()
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:7.3.1'
    }
}

ext.kotlin_version = '1.8.0'
repositories {
    google()
    mavenCentral()
}

字符串
但实际上我没有,ext.kotlin_version没有生效,我在构建应用程序时仍然会收到这些消息:

> Task :lintVitalAnalyzeRelease
e: C:/Users/dmitr/.gradle/caches/modules-2/files-2.1/androidx.annotation/annotation-jvm/1.6.0/a7257339a052df0f91433cf9651231bbb802b502/annotation-jvm-1.6.0.jar!/META-INF/annotation.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.8.0, expected version is 1.6.0.
e: C:/Users/dmitr/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.8.22/636bf8b320e7627482771bbac9ed7246773c02bd/kotlin-stdlib-1.8.22.jar!/META-INF/kotlin-stdlib-jdk7.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.8.0, expected version is 1.6.0.
e: C:/Users/dmitr/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.8.22/636bf8b320e7627482771bbac9ed7246773c02bd/kotlin-stdlib-1.8.22.jar!/META-INF/kotlin-stdlib.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.8.0, expected version is 1.6.0.
e: C:/Users/dmitr/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.8.22/636bf8b320e7627482771bbac9ed7246773c02bd/kotlin-stdlib-1.8.22.jar!/META-INF/kotlin-stdlib-jdk8.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.8.0, expected version is 1.6.0.
e: C:/Users/dmitr/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.8.22/1a8e3601703ae14bb58757ea6b2d8e8e5935a586/kotlin-stdlib-common-1.8.22.jar!/META-INF/kotlin-stdlib-common.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.8.0, expected version is 1.6.0.


当我认为我修复了我的构建时,我忽略了这些消息只在我进行干净构建时出现,而不会出现在后续构建中。
构建成功:

> Task :createDebugBundleListingFileRedirect
> Task :bundleDebug
> Task :bundle

BUILD SUCCESSFUL in 1m 7s
88 actionable tasks: 88 executed


这款应用在安卓设备上运行良好。
我该怎么处理这些信息?忽略它们安全吗?
可能我用ext.Kotlin_version =“1.8.0”指定了一些错误的版本?

编辑1

在我的build.gradle中添加了以下内容:

dependencies {
    implementation(platform("org.jetbrains.kotlin:kotlin-bom:1.8.0"))


dependencies {
    implementation(platform("org.jetbrains.kotlin:kotlin-bom:1.6.0"))


删除了C:\Users\dmitr\.gradle\caches目录和我的构建输出目录,重建了项目,得到了相同的消息。
老实说,我仍然不太明白忽略这些信息是否安全。
也做了the following experiment与这个恼人的疯狂:

classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.0")


看起来我遵循了here的所有步骤。
还能有什么问题

camsedfj

camsedfj1#

看起来将Gradle从7.3.1更新到7.4.1并更新Gradle Package 器最终有所帮助。

相关问题