Reputation: 83
I am new to android studio and I would like to use jackson in an android-studio project. I found two .jar files who seems to make what I am looking for ("jackson-core-asl-1.8.5" and "jackson-mapper-asl-1.8.5"). I have included the dependencies in the app build.graddle like this :
compile 'org.codehaus.jackson:jackson-core-asl:1.8.5'
compile 'org.codehaus.jackson:jackson-mapper-asl:1.8.5'
When I simply build the project it works, but when I run it on the android vm the build fail.
What went wrong: 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\HAL9000\AndroidStudioProjects\EpiAndroid\EpiAndroid\app\libs\jackson-core-asl-1.8.5.jar File2: C:\Users\HAL9000\AndroidStudioProjects\EpiAndroid\EpiAndroid\app\libs\jackson-mapper-asl-1.8.5.jar File3: C:\Users\HAL9000.gradle\caches\modules-2\files-2.1\org.codehaus.jackson\jackson-core-asl\1.8.5\713a5564acb9a5467521bbb53221ab8e1fe65039\jackson-core-asl-1.8.5.jar File4: C:\Users\HAL9000.gradle\caches\modules-2\files-2.1\org.codehaus.jackson\jackson-mapper-asl\1.8.5\56439095aa051521c5abb330235820c66886b5e5\jackson-mapper-asl-1.8.5.jar
Then I tried to add :
packagingOptions {
exclude 'META-INF/NOTICE'
}
in the app build.graddle file but it doesn't work too.
Thanks for your help.
Upvotes: 0
Views: 1990
Reputation: 83
I found the solution by removing the two .jar in /libs, removing my packagingOptions and write this instead :
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
And finally i use this for the dependencies instead:
compile (
[group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.4.1'],
[group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version: '2.4.1'],
[group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.4.1']
)
I hope it will help someone in the future.
Upvotes: 2