Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Duplicate files when adding compiling with Gradle in Android Studio [duplicate]

I am trying to add Jackson to my Android Studio project I do it by adding it to dependencies in 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 build runs fine, however when I want to run tests in Android Studio it gives me the following error:

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

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

Duplicate files copied in APK META-INF/LICENSE File 1: .../.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.core/jackson-annotations/2.4.3/a30ec6f59b6d31b2df06fa73925fda2fc7e84486/jackson-annotations-2.4.3.jar File 2: .../.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.core/jackson-annotations/2.4.3/a30ec6f59b6d31b2df06fa73925fda2fc7e84486/jackson-annotations-2.4.3.jar

I have tried invalidating caches in Android Studio, but it doesn't work. Can somebody help me, please?

like image 286
Savage Reader Avatar asked Oct 14 '14 05:10

Savage Reader


1 Answers

You can exclude it adding this block to your build.gradle:

android {
    packagingOptions {
        exclude 'META-INF/LICENSE.txt'
    }
}
like image 125
Gabriele Mariotti Avatar answered Sep 18 '22 00:09

Gabriele Mariotti