transformClassesWithJarMergingForDebug错误原因以及解决方法

来源:互联网 发布:草履虫软件下载 编辑:程序博客网 时间:2024/05/21 06:36

一、错误信息:

Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: base64decoder.class

二、错误原因

由于项目中使用了多个module,同时引用了该jar包,导致该问题发生,但是该问题只在5.0以下手机出问题,6.0的手机测试时没有问题

三、解决方法

compile
compile是对所有的build type都会参与编译并且打包到最终的apk文件中。

Provided
Provided是对所有的build type只在编译时使用,类似eclipse中的external-libs,只参与编译,不打包到最终apk。


所以需要只在其中一个module使用compile files('libs/sun.misc.base64decoder.jar')的方式添加依赖,将其他module的compile fileTree(include: ['*.jar'], dir: 'libs')注释掉,并使用

provided files('libs/sun.misc.base64decoder.jar')的方式添加依赖。


阅读全文
0 0