如题,在AS编apk的时候,报了如下错误:
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/LICENSE
File1: C:\Users\G\AndroidStudioProjects\SuperMapGTMobile1\app\libs\poi-3.9-20121203.jar
File2: C:\Users\G\AndroidStudioProjects\SuperMapGTMobile1\app\libs\poi-scratchpad-3.9-20121203.jar
意思是在poi-3.9-20121203.jar poi-scratchpad-3.9-20121203.jar两个jar包中APK META-INF/LICENSE 重复了,借鉴了网上的修改方法,我的解决办法如下:
在app的build.gradle中的
android { ... defaultConfig { applicationId "com.supermap.gtmobile" minSdkVersion 15 targetSdkVersion 17 multiDexEnabled true } packagingOptions { exclude 'META-INF/LICENSE' } ... }
添加了packagingOptions { exclude 'META-INF/LICENSE' }意思不要包含 META-INF/LICENSE参考链接:http://stackoverflow.com/questions/34031395/errorexecution-failed-for-task-apptransformresourceswithmergejavaresfordebug