在Android Studio中使用Gradle添加编译时重复文件

时间:2014-10-14 05:02:14

标签: android android-studio gradle android-gradle build.gradle

我正在尝试将Jackson添加到我的Android Studio项目中,我将其添加到gradle中的依赖项中:

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:19.+'
    compile 'com.android.support:support-v4:19.+'
    compile files('libs/universal-image-loader-1.9.2.jar')
    compile 'com.google.android.gms:play-services:+'
    compile 'com.fasterxml.jackson.core:jackson-databind:2.4.3'
}

Gradle构建运行正常,但是当我想在Android Studio中运行测试时,它会给我以下错误:

Error:Gradle: duplicate files during packaging of APK .../app/build/outputs/apk/app-debug-unaligned.apk

Error:Gradle: Execution failed for task ':app:packageDebug'.
  

在APK META-INF / LICENSE中复制的重复文件       文件1:... /。gradle / caches / modules-2 / files-2.1 / com.fasterxml.jackson.core / jackson-annotations / 2.4.3 / a30ec6f59b6d31b2df06fa73925fda2fc7e84486 / jackson-annotations-2.4.3.jar       文件2:... /。gradle / caches / modules-2 / files-2.1 / com.fasterxml.jackson.core / jackson-annotations / 2.4.3 / a30ec6f59b6d31b2df06fa73925fda2fc7e84486 / jackson-annotations-2.4.3.jar

我已尝试在Android Studio中使缓存失效,但它无法正常工作。拜托,有人可以帮助我吗?

1 个答案:

答案 0 :(得分:13)

您可以将此块添加到build.gradle

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