其元数据的二进制版本是1.8.0,预期版本是1.6.0。模块是使用不兼容的 Kotlin 版本编译的

Cod*_*yon 21 kotlin

C:/Users/LENOVO/.gradle/caches/transforms-2/files-2.1/2bcd0a6b95744b6f0ee26f9336bd22eb/jetified-annotation-jvm-1.6.0-beta01.jar!/META-INF/annotation.kotlin_module:模块是用Kotlin 版本不兼容。其元数据的二进制版本是1.8.0,预期版本是1.6.0。

buildscript {
    ext.kotlin_version = '1.4.32'
    ext.anko_version='0.10.8'
    repositories {
        jcenter()
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
      google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:4.1.2'
        classpath 'com.google.gms:google-services:4.3.3'
        classpath 'org.greenrobot:greendao-gradle-plugin:3.2.1'
        classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10'
        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.4.1'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
        // Add the dependency for the Performance Monitoring plugin
        classpath 'com.google.firebase:perf-plugin:1.4.1'
    }
}
Run Code Online (Sandbox Code Playgroud)

Arp*_*tel 7

最近,我在使用 Compose Material3 模板在 Android studio 中创建新项目时遇到了类似的问题。

所以我升级了下面的库/插件解决了我的问题。我还附上了我的 gradle 文件以供参考。

kotlin version to 1.8.0

kotlinCompilerExtensionVersion '1.4.0'

compose_version to 1.3.1

构建.gradle(应用程序)

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

android {
    namespace 'com.example.appname'
    compileSdk 33

    defaultConfig {
        applicationId "com.example.appname"
        minSdk 23
        targetSdk 33
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        vectorDrawables {
            useSupportLibrary true
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = '1.8'
    }
    buildFeatures {
        compose true
    }
    composeOptions {
        kotlinCompilerExtensionVersion '1.4.0'
    }
    packagingOptions {
        resources {
            excludes += '/META-INF/{AL2.0,LGPL2.1}'
        }
    }
}

dependencies {

    implementation 'androidx.core:core-ktx:1.9.0'
    implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.5.1'
    implementation 'androidx.activity:activity-compose:1.6.1'
    implementation "androidx.compose.ui:ui:$compose_version"
    implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
    implementation 'androidx.compose.material3:material3:1.1.0-alpha05'


    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.5'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
    androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"
    debugImplementation "androidx.compose.ui:ui-tooling:$compose_version"
    debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_version"
}
Run Code Online (Sandbox Code Playgroud)

构建.gradle(项目)

    buildscript {
    ext {
        compose_version = '1.3.3'
    }
}// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
    id 'com.android.application' version '7.4.1' apply false
    id 'com.android.library' version '7.4.1' apply false
    id 'org.jetbrains.kotlin.android' version '1.8.0' apply false
}
Run Code Online (Sandbox Code Playgroud)


MrP*_*PNG 1

该项目包含一些不兼容甚至危险的东西,这也会导致您遇到的问题:

  • jcenter()不再使用,因此应该将其替换为mavenCentral(),否则您的依赖项将无法正确解析。
  • 您同时指定了 Kotlin 1.4.32(不再维护)和1.6.10Kotlin(不再理想,但仍然可用),并且它们之间的类肯定不兼容。
  • 您的一些其他依赖项可能更新并使用 Kotlin 1.8.0,因此您的旧运行时将无法读取其元数据。