6

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?

Gabriele Mariotti
  • 250,295
  • 77
  • 670
  • 690
Savage Reader
  • 357
  • 1
  • 4
  • 15

1 Answers1

13

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

android {
    packagingOptions {
        exclude 'META-INF/LICENSE.txt'
    }
}
Gabriele Mariotti
  • 250,295
  • 77
  • 670
  • 690