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

问题描述 投票:0回答:1

我正在尝试为我的 Android 项目生成签名的 APK。调试版本运行完全正常。

我收到以下错误。

`

完成 :app:lintVitalAnalyzeRelease

/Users/shashankbaranwal/.gradle/caches/transforms-3/8414e15dc54d688fdb4e5f88bbf8452d/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/6ba466565903a0f001ab2ae51b33dd90/transformed/core-1.10.0/jars/classes.jar!/META-INF/core_release.kotlin_module:模块是使用不兼容的 Kotlin 版本编译的。其元数据的二进制版本是1.8.0,预期版本是1.6.0。

/Users/shashankbaranwal/.gradle/caches/modules-2/files-2.1/androidx.annotation/annotation-jvm/1.6.0/a7257339a052df0f91433cf9651231bbb802b502/annotation-jvm-1.6.0.jar!/META-INF/注释。 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/e72fc5e03ec6c064c678a6bd0d955c88d55b0c4a/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/e72fc5e03ec6c064c678a6bd0d955c88d55b0c4a/kotlin-stdlib-1.8.20.jar!/META-INF/ kotlin-stdlib.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/e72fc5e03ec6c064c678a6bd0d955c88d55b0c4a/kotlin-stdlib-1.8.20.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/5eddaaf234c8c49d03eebeb6a14feb7f90faca71/kotlin-stdlib-common-1.8.20.jar!/ META-INF/kotlin-stdlib-common.kotlin_module:模块是使用不兼容的 Kotlin 版本编译的。其元数据的二进制版本是1.8.0,预期版本是1.6.0。`

build.gradle(项目名称):

// 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(:应用程序):

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 插件(版本 1.8.0-RC2)。

我也尝试过更改 buildScript 中的 kotlin 版本。

ext.kotlin_version = '1.6.0'

我也尝试过完全删除 buildScript 部分。

下面的链接解决了该问题,但这似乎是一个解决方法。 模块是使用不兼容的 Kotlin 版本编译的。其元数据的二进制版本是1.8.0,预期版本是1.6.0

如何安全地解决这个问题?

android kotlin gradle androidx
1个回答
0
投票

你的问题解决了吗?我有同样的问题。 我的

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'
    }
}
© www.soinside.com 2019 - 2024. All rights reserved.