我正在重建我的Android项目,该项目使用Java编写,其中一些类是用Kotlin编写的。我在谷歌上搜索了一下,但我的问题没有解决。在构建我的项目时,我遇到了以下错误:
/home/bansal/.gradle/caches/transforms-2/files-2.1/0bea321a20a76ca878f594ef198fedcf/jetified-core-ktx-1.10.0-alpha02-api.jar!/META-INF/core-ktx_release.kotlin_module: 模块是使用不兼容的Kotlin版本编译的。其元数据的二进制版本为1.8.0,预期版本为1.6.0。
以下是我的build.gradle文件:
ext.kotlin_version = '1.6.10'
repositories {
google()
jcenter()
maven {
url 'http://dl.bintray.com/amulyakhare/maven'
}
}
dependencies {
classpath "com.android.tools.build:gradle:4.0.1"
classpath 'io.realm:realm-gradle-plugin:3.2.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
和模块 build.gradle
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
dependencies{
implementation 'androidx.core:core-ktx:1.7.0'
annotationProcessor 'android.arch.lifecycle:compiler:1.1.1'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.3.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'android.arch.lifecycle:viewmodel:1.1.1'
implementation 'android.arch.lifecycle:extensions:1.1.1'
//Coroutines
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.1'
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0"
implementation "androidx.core:core-ktx:+"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
尝试的解决方案:模块使用了与 Kotlin 不兼容的编译版本。其元数据的二进制版本为 1.5.1,而期望版本为 1.1.15。