Gradle Build失败[Android]'META-INF / kotlinx-coroutines-core.kotlin_module'

时间:2018-06-09 13:03:55

标签: android gradle

Gradle确实构建了我的小型adroid app。 一段时间后,我添加了一些更多的依赖项,它开始引发此错误消息并且无法构建。

发现了类似的问题,但都声明要排除。没有帮助。 “ 在OS独立路径'META-INF / kotlinx-coroutines-core.kotlin_module'中发现了多个文件 “ 导入看起来像这样 import kotlinx.coroutines.experimental.async

Gradle Build fiel看起来像这样 “

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

android {

    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'
        //exclue  'META-INF/kotlinx-coroutines-core.kotlin_module'
    }
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.example.a18mas.app_mp3"
        minSdkVersion 15
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation"org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    /*_______________________NEW DEPENDENCIES______________________*/
    //local
    implementation files("/libs/ftp4j-1.7.2.jar", "/libs/kotlinx-coroutines-core-0.22.5.jar")

    //public
    implementation 'com.beust:klaxon:3.0.1'
    implementation 'com.github.kittinunf.fuel:fuel:+' //for JVM
    implementation 'com.github.kittinunf.fuel:fuel-android:+' //for Android
    implementation 'com.github.kittinunf.fuel:fuel-livedata:+' //for LiveData support
    implementation 'com.github.kittinunf.fuel:fuel-rxjava:+' //for RxJava support
    implementation 'com.github.kittinunf.fuel:fuel-coroutines:+' //for Kotlin Coroutines support
    implementation 'com.github.kittinunf.fuel:fuel-gson:+' //for Gson support
    implementation 'com.github.kittinunf.fuel:fuel-jackson:+' //for Jackson support
    implementation 'com.github.kittinunf.fuel:fuel-moshi:+' //for Moshi support
    implementation 'com.github.kittinunf.fuel:fuel-forge:+' //for Forge support

}

2 个答案:

答案 0 :(得分:0)

你可能会这样做但是......

  1. 清理并构建项目
  2. 重建Gradle
  3. 重新启动IDE(当我遇到奇怪的gradle问题时,这对我来说很有用)

  4. 检查依赖项的所有版本号

答案 1 :(得分:0)

我和coroutines有同样的问题

implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlin_coroutine_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$kotlin_coroutine_version"

我更新了像这样的packagingOptions

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/main.kotlin_module'
}

一切正常后。