APK错误中的重复文件

时间:2015-06-10 08:18:48

标签: java android

我正在尝试在我的android项目中使用Watson java包装器。我刚刚添加

compile 'com.ibm.watson.developer_cloud:java-wrapper:0.1.4'

到我的gradle,我收到META-INF/LICENSE错误中发现的重复文件。有谁知道如何解决这个问题?

我的 build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"

    defaultConfig {
        applicationId "com.cool.myapp"
        minSdkVersion 15
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.2.0'
    compile 'com.ibm.watson.developer_cloud:java-wrapper:0.1.4'
}

Messages Gradle向我显示

Error:duplicate files during packaging of APK /Users/Shaik/Downloads/AskAshiq/app/build/outputs/apk/app-debug-unaligned.apk
    Path in archive: META-INF/DEPENDENCIES
    Origin 1: /Users/Shaik/.gradle/caches/modules-2/files-2.1/org.apache.james/apache-mime4j/0.6/945007627e8d12275d755081a9e609c018e1210d/apache-mime4j-0.6.jar
    Origin 2: /Users/Shaik/.gradle/caches/modules-2/files-2.1/org.apache.httpcomponents/httpcore/4.0.1/e813b8722c387b22e1adccf7914729db09bcb4a9/httpcore-4.0.1.jar
You can ignore those files in your build.gradle:
    android {
      packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
      }
    }
Error:Execution failed for task ':app:packageDebug'.
> Duplicate files copied in APK META-INF/DEPENDENCIES
    File 1: /Users/Shaik/.gradle/caches/modules-2/files-2.1/org.apache.james/apache-mime4j/0.6/945007627e8d12275d755081a9e609c018e1210d/apache-mime4j-0.6.jar
    File 2: /Users/Shaik/.gradle/caches/modules-2/files-2.1/org.apache.httpcomponents/httpcore/4.0.1/e813b8722c387b22e1adccf7914729db09bcb4a9/httpcore-4.0.1.jar

添加此功能也无济于事

  packagingOptions {
        exclude 'META-INF/LICENSE'
    }

1 个答案:

答案 0 :(得分:1)

尝试通过添加来排除所有文件。

packagingOptions {
    exclude 'META-INF/DEPENDENCIES.txt'
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/NOTICE.txt'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/DEPENDENCIES'
    exclude 'META-INF/notice.txt'
    exclude 'META-INF/license.txt'
    exclude 'META-INF/dependencies.txt'
    exclude 'META-INF/LGPL2.1'
}