Kotlin编译器警告和应用程序无法执行

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

我有一个使用androidx和kotlin的项目,运行应用程序时收到如下错误消息:

w:类路径中的JAR运行时文件应具有相同的版本。这些文件在类路径中找到:

w:/Users/arjava/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jre7/1.2.31/98678431965f7487d6dc9b399e59b6c4b3921073/kotlin-stdlib-jre7-1.2.31.jar: kotlin-stdlib-jre7已弃用。请改用kotlin-stdlib-jdk7

还有一条消息指示我到目录:

.gradle / caches / modules-2 / files-2.1 / org目录。 Jetbrains.kotlin / kotlin-stdlib-jre7 /和xxxxxxx

我真的很困惑这个问题,即使我不在我的app.gradle中应用jre,我尝试删除文件然后会有越来越多。

这是我的app.gradle文件:

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'


android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.mhdfdl41.android.gotoclinic"
        minSdkVersion 16
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    sourceSets { main { assets.srcDirs = ['src/main/assets', 'src/main/assets/'] } }

}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.1.0-alpha01'
    androidTestImplementation "android.arch.core:core-testing:1.1.1"
    implementation 'com.google.android.material:material:1.1.0-alpha03'
    implementation 'com.readystatesoftware.sqliteasset:sqliteassethelper:2.0.1'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'com.github.smarteist:autoimageslider:1.1.1'
    implementation 'com.github.bumptech.glide:glide:4.8.0'
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'com.github.smarteist:autoimageslider:1.1.1'
    implementation 'com.github.bumptech.glide:glide:4.8.0'
    implementation 'com.github.humazed:RoomAsset:1.0.3'
    implementation 'de.hdodenhof:circleimageview:2.2.0'
    implementation 'com.basgeekball:awesome-validation:1.3'
    // AAC (Room, Live Data, View Model)
    implementation "android.arch.persistence.room:runtime:1.1.1"
    kapt "android.arch.persistence.room:compiler:1.1.1"
    kapt "android.arch.lifecycle:compiler:1.1.1"
    // ViewModel and LiveData
    androidTestImplementation "android.arch.persistence.room:testing:1.1.1"
    implementation "android.arch.lifecycle:extensions:$lifecycle_version"

    //room asset access databases
    implementation 'com.github.humazed:RoomAsset:1.0.3'

    testImplementation 'junit:junit:4.12'
    androidTestImplementation "androidx.test.ext:junit:1.1.0"
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
//    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"

    //anko
    implementation "org.jetbrains.anko:anko:$anko_version"
}

configurations {
    all*.exclude group: 'com.google.guava', module: 'listenablefuture'
}
repositories{
    mavenCentral()
}

是什么让这件事发生的

android android-studio kotlin
1个回答
2
投票

这是根项目的build.gradle看起来应该是如何相似的。当我添加kotlin-stdlib-jdk7时,它仍然抱怨版本不匹配;只有kotlin-stdlib(没有postfix)适合我。

buildscript {
    ext.kotlinVersion = "1.3.30"
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath "com.android.tools.build:gradle:3.4.0"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlinVersion}"
    }
}

plugins {
    id "org.jetbrains.kotlin.jvm" version "1.3.30"
}
repositories {
    mavenCentral()
}
dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib:${kotlinVersion}"
}
...
© www.soinside.com 2019 - 2024. All rights reserved.