解决DuplicateFileException: Duplicate files copied in APK META-INF/LICENSE(或META-INF/DEPENDENCIES)(示例
Posted Sharley
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了解决DuplicateFileException: Duplicate files copied in APK META-INF/LICENSE(或META-INF/DEPENDENCIES)(示例相关的知识,希望对你有一定的参考价值。
导入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:\AndroidStudioProjects\android_client\app\libs\wink-json4j-1.4.jar
File2: D:\AndroidStudioProjects\android_client\app\libs\httpclient-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‘ } }
以上是关于解决DuplicateFileException: Duplicate files copied in APK META-INF/LICENSE(或META-INF/DEPENDENCIES)(示例的主要内容,如果未能解决你的问题,请参考以下文章
错误:com.android.builder.packaging.DuplicateFileException: Duplicate files copied
DuplicateFileException m4b + 播放服务 9.0
错误:com.android.builder.packaging.DuplicateFileException: Duplicate files copied
报错transformResourcesWithMergeJavaResForDebug的解决办法