Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio trouble setting up Jackson Parser on gradle

I'm having trouble adding the Jackson Parser dependency to my project.

Currently I'm using these lines of code on my build.gradle:

compile 'com.fasterxml.jackson.core:jackson-core:2.7.2'
compile 'com.fasterxml.jackson.core:jackson-annotations:2.7.2'
compile 'com.fasterxml.jackson.core:jackson-databind:2.7.2'


The only Class I need is the ObjectMapper that I know it is in databind package. When I added these lines in the gradle I pressed the sync and everything did correctly.

The problem was running the project on the emulator, this error showed up in Messages in Android Studio:

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/NOTICE File1: C:\Users\Igor.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-databind\2.7.2\84ffa765dd258dbab8695963c41308b054f3a1cb\jackson-databind-2.7.2.jar File2: C:\Users\Igor.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-core\2.7.2\8b8310381b690e317f5f0574e9b2dd7034778b4c\jackson-core-2.7.2.jar


I tried to left only the databind library but I got no lucky with that. Same error.

compile 'com.fasterxml.jackson.core:jackson-databind:2.7.2'


I tried Build -> Clean Project and deleting the .gradle/cache but no luck either.


I have no clue what this could be. Any suggestions?

like image 662
Igor Morse Avatar asked Mar 10 '16 07:03

Igor Morse


2 Answers

Add

android {
...
packagingOptions {
exclude 'META-INF/NOTICE' // It is not include NOTICE file
exclude 'META-INF/LICENSE' // It is not include LICENSE file
}
...
}

in your build.gradle .

like image 62
pRaNaY Avatar answered Sep 20 '22 12:09

pRaNaY


To resolve the problem entirely I added all of these:

 packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
    }
like image 44
Igor Morse Avatar answered Sep 18 '22 12:09

Igor Morse