【问题标题】:Kotlin the compiler warning and application cannot be executedKotlin 编译器警告和应用程序无法执行
【发布时间】:2019-06-27 15:43:20
【问题描述】:

我有一个使用 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】:

    这就是根项目的build.gradle 应该看起来像的样子。当我添加kotlin-stdlib-jdk7 时,它仍然抱怨版本不匹配;只有kotlin-stdlib(没有后缀)对我有用。

    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}"
    }
    ...
    

    【讨论】:

    • compile 应避免使用 - 它已被 implementation 取代
    猜你喜欢
    • 2018-11-03
    • 1970-01-01
    • 2012-11-19
    • 1970-01-01
    • 1970-01-01
    • 2012-12-23
    • 2014-10-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多