Android应用未构建:在APK META-INF / INDEX.LIST中复制的重复文件

时间:2016-03-30 03:23:46

标签: android android-studio gradle android-gradle

当我尝试运行Android应用时,我收到以下错误。

Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.
> com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/INDEX.LIST
    File1: /Users/Antrromet/.gradle/caches/modules-2/files-2.1/org.apache.xmlbeans/xmlbeans/2.6.0/29e80d2dd51f9dcdef8f9ffaee0d4dc1c9bbfc87/xmlbeans-2.6.0.jar
    File2: /Users/Antrromet/.gradle/caches/modules-2/files-2.1/edu.ucar/cdm/4.5.5/af1748a3d024069cb7fd3fc2591efe806c914589/cdm-4.5.5.jar
    File3: /Users/Antrromet/.gradle/caches/modules-2/files-2.1/edu.ucar/httpservices/4.5.5/ee5f217be599e5e03f7f0e55e03f9e721a154f62/httpservices-4.5.5.jar
    File4: /Users/Antrromet/.gradle/caches/modules-2/files-2.1/edu.ucar/netcdf4/4.5.5/675d63ecc857c50dd50858011b670160aa30b62/netcdf4-4.5.5.jar
    File5: /Users/Antrromet/.gradle/caches/modules-2/files-2.1/edu.ucar/grib/4.5.5/cfe552910e9a8d57ce71134796abb281a74ead16/grib-4.5.5.jar
    File6: /Users/Antrromet/.gradle/caches/modules-2/files-2.1/edu.ucar/udunits/4.5.5/d8c8d65ade13666eedcf764889c69321c247f153/udunits-4.5.5.jar

我知道有类似的问题herehere,我已经从他们两个人那里得到了提示。这就是我的gradle文件的样子。

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "com.antrromet.androidtikaparser"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'

        exclude 'META-INF/maven/edu.ucar/udunits/pom.xml'
        exclude 'META-INF/maven/edu.ucar/udunits/pom.properties'

        exclude 'META-INF/maven/edu.ucar/netcdf4/pom.xml'
        exclude 'META-INF/maven/edu.ucar/netcdf4/pom.properties'

        exclude 'META-INF/maven/edu.ucar/cdm/pom.xml'
        exclude 'META-INF/maven/edu.ucar/cdm/pom.properties'

        exclude 'META-INF/maven/edu.ucar/grib/pom.xml'
        exclude 'META-INF/maven/edu.ucar/grib/pom.properties'

        exclude 'META-INF/maven/org.apache.xmlbeans/xmlbeans/pom.xml'
        exclude 'META-INF/maven/org.apache.xmlbeans/xmlbeans/pom.properties'

        exclude 'META-INF/maven/edu.ucar/httpservices/pom.xml'
        exclude 'META-INF/maven/edu.ucar/httpservices/pom.properties'
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.2.1'
    compile('org.apache.tika:tika-parsers:1.12') {
        exclude group: 'commons-logging', module: 'commons-logging'
        exclude group: 'org.json', module: 'json'
        exclude group: 'org.apache.httpcomponents', module: 'httpclient'
    }
}

有关如何解决此问题的任何建议?提前谢谢!

编辑1

当我添加exclude 'META-INF/INDEX.LIST'时,错误会更改为以下内容,

Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.
> com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/services/org.apache.sis.storage.DataStoreProvider
    File1: /Users/Antrromet/.gradle/caches/modules-2/files-2.1/org.apache.sis.storage/sis-storage/0.5/29d1ea6422b68fbfe1f1702f122019ae376ee2c8/sis-storage-0.5.jar
    File2: /Users/Antrromet/.gradle/caches/modules-2/files-2.1/org.apache.sis.storage/sis-netcdf/0.5/2b416e4506caebe7df6dd21b878dae888e0eea39/sis-netcdf-0.5.jar

之后如果添加以下内容,

exclude 'META-INF/maven/org.apache.sis.storage/sis-netcdf/pom.xml'
exclude 'META-INF/maven/org.apache.sis.storage/sis-netcdf/pom.properties'

exclude 'META-INF/maven/org.apache.sis.storage/sis-storage/pom.xml'
exclude 'META-INF/maven/org.apache.sis.storage/sis-storage/pom.properties'

与上面完全相同的错误。它没有变化。

1 个答案:

答案 0 :(得分:1)

您需要添加以下排除:

exclude 'META-INF/services/org.apache.sis.storage.DataStoreProvider'