Kotlin version issues: The binary version of its metadata is 1.8.0, expected version is 1.6.0. Not working by changing the version in build.gradle

huangapple go评论119阅读模式
英文:

Kotlin version issues: The binary version of its metadata is 1.8.0, expected version is 1.6.0. Not working by changing the version in build.gradle

问题

我遇到了Kotlin版本不兼容的问题。我已经对我的项目级别的build.gradle文件进行了更改,但问题仍然存在。

在Gradle同步之后,我收到了以下错误:
C:/Users/ADMIN/.gradle/caches/8.0.1/generated-gradle-jars/gradle-api-8.0.1.jar!/META-INF/configuration-cache.kotlin_module:此模块是使用不兼容的Kotlin版本编译的。其元数据的二进制版本为1.8.0,期望版本为1.6.0。

build.gradle

buildscript {
    ext {
        buildToolsVersion = "31.0.0"
        minSdkVersion = 24
        compileSdkVersion = 31
        kotlinVersion = "1.6.0"
        targetSdkVersion = 31
        googlePlayServicesAuthVersion = "19.2.0"

        if (System.properties['os.arch'] == "aarch64") {
            // 对于M1用户,我们需要使用支持aarch64的NDK 24
            ndkVersion = "24.0.8215888"
        } else {
            // 否则,我们默认使用AGP提供的NDK版本
            ndkVersion = "21.4.7075529"
        }
    }
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:7.2.1'
        classpath 'com.google.gms:google-services:4.3.14'
        classpath "com.facebook.react:react-native-gradle-plugin"
        classpath "de.undercouch:gradle-download-task:5.0.1"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
    }
}

allprojects {
    repositories {
        google()
        maven {
            url "$rootDir/../node_modules/react-native/android"
        }
        maven {
            url "$rootDir/../node_modules/jsc-android/dist"
        }
        maven {
            url "https://www.jitpack.io"
        }
        mavenCentral {
            content {
                excludeGroup "com.facebook.react"
            }
        }
    }
}

请检查你的项目中的Kotlin版本与Gradle和其他依赖项的版本兼容性,确保它们都使用相同的Kotlin版本。

英文:

I am getting kotlin version incompatibility issue. I had made changes to my project level build.gradle file then also the issue persist.

I am getting the following error after Gradle sync:
C:/Users/ADMIN/.gradle/caches/8.0.1/generated-gradle-jars/gradle-api-8.0.1.jar!/META-INF/configuration-cache.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.

build.gradle

buildscript {
    ext {
        buildToolsVersion = "31.0.0"
        minSdkVersion = 24
        compileSdkVersion = 31
        kotlinVersion = "1.6.0"
        targetSdkVersion = 31
        googlePlayServicesAuthVersion = "19.2.0"

        if (System.properties['os.arch'] == "aarch64") {
            // For M1 Users we need to use the NDK 24 which added support for aarch64
            ndkVersion = "24.0.8215888"
        } else {
            // Otherwise we default to the side-by-side NDK version from AGP.
            ndkVersion = "21.4.7075529"
        }
    }
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath('com.android.tools.build:gradle:7.2.1')
        classpath 'com.google.gms:google-services:4.3.14'
        classpath("com.facebook.react:react-native-gradle-plugin")
        classpath("de.undercouch:gradle-download-task:5.0.1")
        classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
    }
}

allprojects {
    repositories {
        google()
        maven {
            url "$rootDir/../node_modules/react-native/android"
        }
        maven {
            url "$rootDir/../node_modules/jsc-android/dist"
        }
        maven {
            url "https://www.jitpack.io"
        }
        mavenCentral {
            content {
                excludeGroup "com.facebook.react"
            }
        }
    }
}

答案1

得分: 2

看起来是Gradle版本兼容性问题。

你可以尝试升级Kotlin版本到1.8(在build.gradle中进行修改)。

或者降级Gradle版本至7.6以下(在project/gradle/gradle-wrapper.properties中进行修改)。

关于Gradle版本兼容性的更多信息请参考:
https://docs.gradle.org/current/userguide/compatibility.html#kotlin

英文:

Looks like a gradle version compatibility issue.

You can try to upgrade the kotlin version to 1.8(Modify in build.gradle).

Or downgrade the gradle version to below 7.6(Modify in project/gradle/gradle-wrapper.properties).

See more about gradle version compatibility:
https://docs.gradle.org/current/userguide/compatibility.html#kotlin

答案2

得分: 1

更新 Kotlin 版本:

buildscript {
    ext.kotlin_version = '1.8.0'
英文:

update the the kotlin version

buildscript {
    ext.kotlin_version = '1.8.0'

huangapple
  • 本文由 发表于 2023年3月3日 18:45:18
  • 转载请务必保留本文链接:https://go.coder-hub.com/75626057.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定