Description of the error
Today, I added the Jackson development package to the Android Studio project, which was compiled at the time of execution. An error such as the following is raised:
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: D:\Code\XTCKuwoWatch\app\libs\jackson-core-2.4.4.jar File2: D:\Code\XTCKuwoWatch\app\libs\jackson-databind-2.4.4.jar
Errors such as the following are seen:
How to Solve
This appears to be due to the inclusion of the same file (NOTICE.txt) in multiple jar packages. Causes errors when packaging is caused by worrying about each other's coverage issues. Try adding a configuration in the Android section of Build.gradle under app. As the following code sees:
{ exclude ‘META-INF/LICENSE‘ exclude ‘META-INF/NOTICE‘ }
- Build.gradle file before the change
apply plugin: ' com.android.application ' android { Compilesdkversion 22 buildtoolsversion "22.0.1" defaultconfig {applicationid "com.oyp.csdn" minsdkversion 16 targetsdkversion 23 versioncode 1 versionname " 1.0 "} buildtypes {release {min ifyenabled false proguardfiles getdefaultproguardfile ( ' proguard-android.txt ' ), ' Proguard-rules.pro ' }}}dependencies {C Ompile Filetree (dir : ' Libs ' , include: [ ' *.jar ' ])}
- Build.gradle files after the change
Apply plugin:' Com.android.application 'Android {Compilesdkversion ABuildtoolsversion"22.0.1"packagingoptions {Exclude' Meta-inf/license 'Exclude' Meta-inf/notice '} defaultconfig {ApplicationID"COM.OYP.CSDN"Minsdkversion -Targetsdkversion atVersioncode1Versionname"1.0"} buildtypes {release {minifyenabledfalseProguardfiles Getdefaultproguardfile (' Proguard-android.txt '),' Proguard-rules.pro '}}}dependencies {Compile Filetree (dir:' Libs ', include: [' *.jar '])}
欧阳鹏 欢迎转载,与人分享是进步的源泉!转载请保留原文地址:http://blog.csdn.net/ouyang_peng
My Android Advanced tour------> resolution: Execution failed for task & #39;: App:transformresourceswithmergejavaresfordebug & #39;.