类路径中的运行时 JAR 文件的版本为 1.4,该版本比 API 版本 1.5 旧?

Meg*_*Sam 11 android kotlin build.gradle

我在尝试构建应用程序的发布版本时遇到此错误。我没有使用 kotlin 依赖项,所以有人可以告诉我如何解决这个问题吗?

错误日志:

类路径中的运行时 JAR 文件的版本为 1.4,该版本早于 API 版本 1.5。考虑使用版本 1.5 的运行时,或显式传递“-api-version 1.4”以将可用 API 限制为版本 1.4 的运行时。您还可以传递“-language-version 1.4”,这不仅会将 API 限制为指定版本,还会限制语言功能:/Users/meggan/.gradle/caches/modules-2/files-2.1/ org.jetbrains.kotlin/kotlin-stdlib-jdk7/1.4.32/3546900a3ebff0c43f31190baf87a9220e37b7ea/kotlin-stdlib-jdk7-1.4.32.jar:

我的 build.gradle (应用程序):

buildscript {
    repositories {
        google()
        maven { url 'https://plugins.gradle.org/m2/' }
    }

}

plugins {
    id 'com.android.application'
    id 'com.onesignal.androidsdk.onesignal-gradle-plugin'
    id 'com.google.gms.google-services'
    id 'com.google.firebase.crashlytics'
}

android {
    compileSdkVersion 30
    buildToolsVersion '30.0.3'
    defaultConfig {
        applicationId "com.myapp.app"
        minSdkVersion 21
        targetSdkVersion 30
        versionCode 10
        versionName "1.0"
        vectorDrawables.useSupportLibrary = true
        resConfigs "en"
    }

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

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/ASL2.0'
        exclude("META-INF/*.kotlin_module")
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])

    // Google Design & Support Dependency
    implementation 'androidx.appcompat:appcompat:1.3.1'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'com.google.android.material:material:1.4.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.0'
    implementation 'androidx.recyclerview:recyclerview:1.2.1'
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'androidx.palette:palette:1.0.0'
    implementation 'androidx.annotation:annotation:1.2.0'

    // Layout Libs
    implementation 'com.github.bumptech.glide:glide:4.12.0'
    implementation 'com.squareup.picasso:picasso:2.71828'
    implementation 'com.wang.avi:library:2.1.3'
    implementation 'com.ogaclejapan.smarttablayout:library:2.0.0@aar'

    // Connectivity Libs
    implementation 'com.squareup.retrofit2:retrofit:2.9.0'
    implementation 'com.google.code.gson:gson:2.8.8'
    implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
    implementation 'com.android.volley:volley:1.2.1'

    // Firebase
    implementation platform('com.google.firebase:firebase-bom:28.4.1')
    implementation 'com.google.firebase:firebase-analytics'
    implementation 'com.google.firebase:firebase-config'
    implementation 'com.google.firebase:firebase-crashlytics'

    // OneSignal
    implementation 'com.onesignal:OneSignal:[4.0.0, 4.99.99]'

}
Run Code Online (Sandbox Code Playgroud)

项目构建.gradle:

buildscript {
    repositories {
        google()
        jcenter()
        mavenCentral()
        gradlePluginPortal()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:7.0.2'
        classpath 'com.google.gms:google-services:4.3.10'
        classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.12.10, 0.99.99]'

        // Add the Crashlytics Gradle plugin
        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.7.1'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        mavenCentral()
        maven {
            url "https://jitpack.io"
        }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
Run Code Online (Sandbox Code Playgroud)

Meg*_*Sam 11

只需在 Android Studio 上运行Invalidate Caches / Restart即可修复此问题!

  • 有趣的是,它对 CircleCI 没有帮助:( (3认同)