导入eclipse项目时报
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: D:AndroidStudioProjectsandroid_clientapplibswink-json4j-1.4.jar
File2: D:AndroidStudioProjectsandroid_clientapplibshttpclient-4.5.2.jar
解决办法很简单,在对应报错的模块的build.gradle中添加如下配置即可
android { ... //为了解决部分第三方库重复打包了META-INF的问题 packagingOptions { exclude 'META-INF/LICENSE.txt' exclude 'META-INF/LICENSE' } }
注意红色字体报的什么就加入什么,列出可能会出现的其他错误解决:
android { packagingOptions { exclude 'META-INF/DEPENDENCIES.txt' exclude 'META-INF/DEPENDENCIES' exclude 'META-INF/LICENSE.txt' exclude 'META-INF/LICENSE' exclude 'META-INF/NOTICE.txt' exclude 'META-INF/NOTICE' exclude 'META-INF/notice.txt' exclude 'META-INF/license.txt' exclude 'META-INF/dependencies.txt' exclude 'META-INF/LGPL2.1' } }