【问题标题】:Issue while gradle build Duplicate files copied in APK META-INF/LICENSE在 APK META-INF/LICENSE 中复制 gradle build 时出现问题
【发布时间】:2017-01-29 04:13:34
【问题描述】:
Execution failed for task `:app:transformResourcesWithMergeJavaResForDebug`.
 com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/LICENSE
    File1: C:\Users\admin\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-annotations\2.2.2\285cb9c666f0f0f3dd8a1be04e1f457eb7b15113\jackson-annotations-2.2.2.jar
    File2: C:\Users\admin\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-core\2.2.2\d20be6a5ddd6f8cfd36ebf6dea329873a1c41f1b\jackson-core-2.2.2.jar
    File3: C:\Users\admin\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-databind\2.2.2\3c8f6018eaa72d43b261181e801e6f8676c16ef6\jackson-databind-2.2.2.jar

我尝试过使用

packagingOptions {
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/license.txt'
}

这可行,但我不想排除许可证,请告诉我如何在不使用它的情况下避免它

apply plugin: 'com.android.application'

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.2"

    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
         release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'

    compile 'com.android.support:appcompat-v7:24.2.1'
    compile 'com.android.support:support-v4:24.2.1'
    compile 'com.android.support:design:24.2.1'

    compile 'com.google.firebase:firebase-core:9.4.0'
    compile 'com.google.firebase:firebase-storage:9.4.0'
    compile 'com.google.firebase:firebase-messaging:9.4.0'
    compile 'com.google.firebase:firebase-auth:9.4.0'
    compile 'com.firebase:firebase-client-android:2.5.2'

    compile 'com.squareup.retrofit2:retrofit:2.1.0'
    compile 'com.squareup.okhttp3:okhttp:3.4.1'
    compile 'com.squareup.retrofit:converter-gson:2.0.0-beta2'
}

这是我的 gradle,它有很多依赖项,所以请告诉我是哪些依赖项导致了问题

【问题讨论】:

标签: android firebase


【解决方案1】:

编辑:如果您想使用已定义的依赖项。您需要使用以下代码:

 packagingOptions {
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/license.txt'
    }

否则您需要删除使用的依赖项,因为它们在文件中存在冲突。

【讨论】:

  • 这是一件事,我不想排除为什么我将它与我不寻找的当前解决方案一起发布的许可证。还是谢谢
  • 好的,那么您需要更改依赖项,因为依赖项在 License.txt 文件中发生冲突。
  • 但是你能帮我找出导致问题的依赖项,这将是一个很大的帮助。
  • firebase相关的依赖,如果你需要所有这些你需要使用上面的代码。
【解决方案2】:

您正在混合使用 Firebase 客户端的版本,这肯定会给您带来更多问题。

对所有 Firebase 依赖项使用单一版本,例如 9.4.0:

compile 'com.google.firebase:firebase-core:9.4.0'
compile 'com.google.firebase:firebase-storage:9.4.0'
compile 'com.google.firebase:firebase-messaging:9.4.0'
compile 'com.google.firebase:firebase-auth:9.4.0'
compile 'com.google.firebase:firebase-database:9.4.0' // this one changed

【讨论】:

    【解决方案3】:

    包装选项 { pickFirst 'META-INF/许可证' }

    我试过了,效果很好,请尝试一下。

    【讨论】:

    • 这与@AndroidGeek 的回答相同。但不要在 Firebase SDK 中混合使用各种功能的版本。这是解决问题的秘诀。
    • 我完全同意,因为我发现问题出在 gsm 服务上。感谢您的帮助
    猜你喜欢
    • 2017-12-08
    • 2017-05-25
    • 1970-01-01
    • 2016-04-21
    • 2016-12-13
    • 2017-02-09
    • 2016-10-01
    • 2019-12-20
    • 1970-01-01
    相关资源
    最近更新 更多