8

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?

Igor Morse
  • 657
  • 2
  • 8
  • 20
  • Here is the Maven Link to Jackson Repositories: [link](http://mvnrepository.com/artifact/com.fasterxml.jackson.core) `Jackson` – Igor Morse Mar 10 '16 at 07:09

3 Answers3

9

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 .

pRaNaY
  • 24,642
  • 24
  • 96
  • 146
9

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'
    }
Igor Morse
  • 657
  • 2
  • 8
  • 20
0
implementation 'com.squareup.retrofit2:converter-jackson:2.7.2'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.10.3'
implementation 'com.fasterxml.jackson.core:jackson-core:2.10.3'
implementation 'com.fasterxml.jackson.core:jackson-annotations:2.10.3'

try this..

ref :-

https://mobikul.com/how-to-use-jackson-parser/

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community May 13 '22 at 06:49