Error:Execution failed for task ':testPic:transformResourcesWithMergeJavaResForDebug'.

来源:互联网 发布:个人简历制作模板软件 编辑:程序博客网 时间:2024/06/06 01:18

今天在项目中加入了httpmime-4.0.jar和apache-mime4j-0.6.jar两个包后,运行时就出现了下面的错误:

Error:Execution failed for task ':testPic:transformResourcesWithMergeJavaResForDebug'.
> com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/DEPENDENCIES
File1: E:\androidstudio\StorageSystem\testPic\libs\apache-mime4j-0.6.jar
File2: E:\androidstudio\StorageSystem\testPic\libs\httpmime-4.0.jar

错误截图如下:


开始在网上找了解决办法:

放下如下:

看起来是因为多个 jar 包里包含了同样的文件(NOTICE.txt),导致打包时因为担心相互覆盖问题而提示出错。 尝试下在 app 下的 build.gradle 中的 android 部分增加一段配置,如下面这段代码所示:

packagingOptions{

exclude'META-INF/LICENSE'

exclude'META-INF/NOTICE'

}

这样试过了,还是没有解决问题。

最后仔细检查了一下发现:错误是出现在in APK META-INF/DEPENDENCIES,也就是DEPENDENCIES文件。所以build.gradle 中增加的配置如下:

packagingOptions {    exclude 'META-INF/NOTICE' // will not include NOTICE file    exclude 'META-INF/LICENSE' // will not include LICENSE file    exclude 'META-INF/DEPENDENCIES' // will not include LICENSE file}

所以大家要根据自己错误的实际情况来看。
阅读全文
0 0
原创粉丝点击