Android Studio 0.8.14:在打包APK期间复制文件

时间:2014-12-15 14:16:43

标签: android gradle apk packing

尝试使用Android Studio 0.8.14构建我的应用时,出现以下错误:

Error:duplicate files during packaging of APK C:\Users\pc2_2\Desktop\DOSTTracker\app\build\outputs\apk\app-debug-unaligned.apk
    Path in archive: META-INF/LICENSE
    Origin 1: C:\Users\pc2_2\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-databind\2.4.4\e2ff13c3de2f5a2ab2449a3dace2b0d1c37bd8ee\jackson-databind-2.4.4.jar
    Origin 2: C:\Users\pc2_2\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-annotations\2.4.4\d3dad1a494f94579fca4b6a1142fb15fb68f0b2f\jackson-annotations-2.4.4.jar
You can ignore those files in your build.gradle:
    android {
      packagingOptions {
        exclude 'META-INF/LICENSE'
      }
    }
Error:Execution failed for task ':app:packageDebug'.
> Duplicate files copied in APK META-INF/LICENSE
    File 1: C:\Users\pc2_2\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-databind\2.4.4\e2ff13c3de2f5a2ab2449a3dace2b0d1c37bd8ee\jackson-databind-2.4.4.jar
    File 2: C:\Users\pc2_2\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-databind\2.4.4\e2ff13c3de2f5a2ab2449a3dace2b0d1c37bd8ee\jackson-databind-2.4.4.jar

这是我的build.gradle文件:

apply plugin: 'com.android.library'

android {
    compileSdkVersion 17
    buildToolsVersion "20.0.0"

    defaultConfig {
        applicationId "org.ajwcc.locationtracker"
        minSdkVersion 11
        targetSdkVersion 17
    }

    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

dependencies {
    compile 'com.android.support:support-v4:18.0.0'
    compile 'com.google.android.gms:play-services:6.5.+'
    compile 'com.fasterxml.jackson.core:jackson-annotations:2.4.4'
    compile 'com.fasterxml.jackson.core:jackson-core:2.4.4'
    compile 'com.fasterxml.jackson.core:jackson-databind:2.4.4'
    compile 'org.apache.directory.studio:org.apache.commons.codec:1.8'
}

android {
    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'
    }
}

我已按Android Studio和其他SO帖子的建议添加了packagingOptions,但我仍然收到错误消息。我错过了什么?

1 个答案:

答案 0 :(得分:3)

我弄明白了这个问题。我从另一个应用程序引用此应用程序作为依赖项,并正在构建其他应用程序。我还必须将packagingOptions包含在另一个应用程序的build.gradle文件中。