gradle (生成签名的APK)模块使用不兼容的Kotlin版本编译,元数据的二进制版本为1.8.0,预期版本为1.6.0

sr4lhrrt  于 4个月前  发布在  Kotlin
关注(0)|答案(1)|浏览(84)

我正在尝试为我的Android项目生成一个签名的APK。Android版本运行完全正常。
我正在跟踪错误。
`
完成:app:lintVitalAnalyzeRelease
/Users/shashankbaranwal/.gradle/caches/transforms-3/8414 e15 dc 54 d 688 fdb 4 e5 f88 bbf 8452 d/transformed/jetified-core-ktx-1.10.0/jars/classes.jar!/META-INF/core-ktx_release.Kotlin_module:模块使用不兼容的Kotlin版本编译。其元数据的二进制版本为1.8.0,预期版本为1.6.0。
/Users/shashankbaranwal/.gradle/caches/transforms-3/6 ba 466565903 a0 f001 ab 2ae 51 b33 dd 90/transformed/core-1.10.0/jars/classes.jar!/META-INF/core_release.Kotlin_模块:模块使用不兼容的Kotlin版本编译。其元数据的二进制版本为1.8.0,预期版本为1.6.0。
/Users/shashankbaranwal/.gradle/caches/modules-2/files-2.1/androidx.annotation/annotation-jvm/1.6.0/a7257339 a052 df 0 f91433 cf 9651231 bbb 802 b502/annotation-jvm-1.6.0.jar!/META-INF/annotation.Kotlin_模块:模块使用不兼容的Kotlin版本编译。其元数据的二进制版本为1.8.0,预期版本为1.6.0。
/Users/shashankbaranwal/.gradle/caches/modules-2/files-2.1/org.jetbrains.Kotlin/kotlin-stdlib/1.8.20/e72 fc 5e 03 ec 6c 064 c678 a6 bd 0 d955 c88 d55 b 0 c4 a/kotlin-stdlib-1.8.20.jar!/META-INF/kotlin-stdlib-jdk7.kotlin_module:模块使用不兼容的Kotlin版本编译。其元数据的二进制版本为1.8.0,预期版本为1.6.0。
/Users/shashankbaranwal/.gradle/caches/modules-2/files-2.1/org.jetbrains.Kotlin/kotlin-stdlib/1.8.20/e72fbits@5e03ec6c064c678a6bd0d955c88d55b0c4a/kotlin-stdlib-1.8.20.jar!/META-INF/kotlin-stdlib.Kotlin_模块:模块是使用不兼容的Kotlin版本编译的。其元数据的二进制版本为1.8.0,预期版本为1.6.0。
/Users/shashankbaranwal/.gradle/caches/modules-2/files-2.1/org.jetbrains.Kotlin/kotlin-stdlib/1.8.20/e72 fc 5e 03 ec 6c 064 c678 a6 bd 0 d955 c88 d55 b 0 c4 a/jar!/META-INF/kotlin-stdlib-jdk8.kotlin_module:模块使用不兼容的Kotlin版本编译。其元数据的二进制版本为1.8.0,预期版本为1.6.0。
/Users/shashankbaranwal/.gradle/caches/modules-2/files-2.1/org.jetbrains.Kotlin/kotlin-stdlib-common/1.8.20/5edda af 234 c8 c49 d 03 eebeb 6a 14 feb 7 f90 faca 71/kotlin-stdlib-common-1.8.20.jar!/META-INF/kotlin-stdlib-common.Kotlin_模块:模块是使用不兼容的Kotlin版本编译的。其元数据的二进制版本为1.8.0,版本是1.6.0。
build.gradle(Project_name):

// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
    id 'com.android.application' version '7.3.1' apply false
    id 'com.android.library' version '7.3.1' apply false
    id 'org.jetbrains.kotlin.android' version '1.8.20' apply false
}

字符串
build.gradle(:app):

buildscript {

    ext {
        kotlin_version = '1.8.0'
    }
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:7.1.3'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

plugins {
    id 'com.android.application'
    id 'org.jetbrains.kotlin.android'
}

android {
    namespace 'com.apptest.testpoc'
    compileSdk 33

    defaultConfig {
        applicationId "com.apptest.testpoc"
        minSdk 24
        targetSdk 33
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'),
                          'proguard-rules.pro'
        }
    }

     buildFeatures{
        viewBinding true
    }
    compileOptions {
        sourceCompatibility JavaVersion
                                    .VERSION_1_8
        targetCompatibility JavaVersion
                                    .VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = '1.8'
    }
}

dependencies {

    implementation 'androidx.core:core-ktx:1.10.0'
    implementation 'androidx.appcompat:appcompat-resources:1.6.1'
    implementation 'com.google.android.material:material:1.8.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'

    implementation 'io.agora.rtc:full-sdk:4.0.1'
}


我在IDE中使用最新的Kotlin插件(build 1.8.0-RC 2)。
我还尝试在buildScript中更改Kotlin版本。

ext.kotlin_version = '1.6.0'


我也试过完全删除buildScript部分。
下面的链接解决了这个问题,但它似乎是一个解决办法。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
如何安全地解决此问题?

xzv2uavs

xzv2uavs1#

你解决了你的问题吗?我也有同样的问题。我的app/build.gradle文件:

apply plugin: 'com.android.application'
apply plugin: 'com.huawei.agconnect'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
    compileSdkVersion 33

    lintOptions {
        disable 'InvalidPackage'
        abortOnError false
    }
    // flutter_local_notification
    compileOptions {
        // Flag to enable support for the new language APIs
        coreLibraryDesugaringEnabled true
        // Sets Java compatibility to Java 8
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId ""
        minSdkVersion 20
        targetSdkVersion 33
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
//        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
    }
    packagingOptions {
        exclude 'META-INF/com.android.tools/proguard/coroutines.pro'
    }
}

字符串
build.gradle(project)

buildscript {
    ext.kotlin_version = '1.7.0'
    repositories {
        maven{
            url{'https://maven.aliyun.com/nexus/content/groups/public/'}
        }
        google()
        maven {url 'https://developer.huawei.com/repo/'}
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:7.3.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.huawei.agconnect:agcp:1.6.0.300'
    }
}

相关问题