Kotlin:其元数据的二进制版本为1.8.0,期望版本为1.6.0。

4

我有一个用React Native编写的应用程序,我正在尝试将其上传到Google Play商店,但是在尝试编译.aab文件时遇到了一些问题。

每当我尝试重新加载我的gradle项目时,我都会看到356个错误,所有这些错误都与用于编译的kotlin版本有关。

(这是错误消息: e: E: ... \App\node_modules\react-native-gradle-plugin\src\main\kotlin\com\facebook\react\utils\TaskUtils.kt: (24, 12): Class 'kotlin.collections.ArraysKt___ArraysKt' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.8.0, expected version is 1.6.0.

该类从C:/Users/USERNAME/.gradle/wrapper/dists/gradle-8.0-rc-1-bin/di0yrgntpr7ydpxe8yasu72eh/gradle-8.0-rc-1/lib/kotlin-stdlib-1.8.0-RC2.jar!/kotlin/collections/ArraysKt___ArraysKt.class中加载

我已经更改了我的build.gradle文件,以包括当前版本的gradle和kotlin,它看起来像这样:


buildscript {
    ext.kotlin_version = '1.8.0'
    ext {
        buildToolsVersion = "31.0.0"
        minSdkVersion = 21
        compileSdkVersion = 31
        targetSdkVersion = 31
        //kotlin_version = '1.8.0' //use latest

        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"
        }
    }
    //ext.kotlin_version = '1.7.21' //use latest

    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath("com.android.tools.build:gradle:8.0.0-alpha11")
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath("com.android.tools.build:gradle:8.0.0-alpha11")
        classpath("com.facebook.react:react-native-gradle-plugin")
        classpath("de.undercouch:gradle-download-task:5.0.1")
        //implementation "org.jetbrains.kotlin:kotlin-stdlib:1.8.0"
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url("$rootDir/../node_modules/react-native/android")
        }
        maven {
            // Android JSC is installed from npm
            url("$rootDir/../node_modules/jsc-android/dist")
        }
        mavenCentral {
            // We don't want to fetch react-native from Maven Central as there are
            // older versions over there.
            content {
                excludeGroup "com.facebook.react"
            }
        }
        google()
        maven { url 'https://www.jitpack.io' }
    }
}

任何帮助都将不胜感激!
1个回答

0

1、ext.kotlin_version = '1.6.0'

2、在项目的build.gradle中进行以下设置:

将"org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"版本更改为"org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.0"

3、在应用的build.gradle中进行以下设置:

检查'androidx.core:core-ktx:1.6.0'版本

因为"$kotlin_version"属性已经更新


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接