Android transformClassesWithDexForAdh5Debug 的解决方法

来源:互联网 发布:安卓解压软件 编辑:程序博客网 时间:2024/06/03 22:17

1 遇到的问题

开发中遇到下面一个运行错误:

Error:Execution failed for task ':hello_v1.0:transformClassesWithDexForAdh5Debug'.> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'D:\Program Files\Java\jdk1.8.0_65\bin\java.exe'' finished with non-zero exit value 2> 

如果使用了友盟或者百度地图,则还会在运行时报下面一排警告:

Warning:Ignoring InnerClasses attribute for an anonymous inner class(org.dom4j.swing.LeafTreeNode$1) that doesn't come with anassociated EnclosingMethod attribute. This class was probably produced by acompiler that did not target the modern .class file format. The recommendedsolution is to recompile the class from source, using an up-to-date compilerand without specifying any "-target" type options. The consequence of ignoringthis warning is that reflective operations on this class will incorrectlyindicate that it is *not* an inner class.

如下图:

这里写图片描述

这里写图片描述

这里写图片描述

2 原因

博主是在集成一个库的时候,编译通过,运行时报上面的错误,可是之前集成过一次,明明可以运行的,同样的方法再次集成就不行了。最后发现是因为方法数太多了,超过了限制

3 解决方法

在build.gradle中添加下面代码:

defaultConfig {    ......       multiDexEnabled true}

4 参考链接

我是参考下面的博客解决问题的:

http://blog.csdn.net/zouchengxufei/article/details/50011237

顺便贴一下StackOverflow上关于这个问题的解答:

http://stackoverflow.com/questions/33095536/apptransformclasseswithdexfordebug-com-Android-build-transform-api-transf

5 转载请注明来自”梧桐那时雨”的博客:http://blog.csdn.net/fuchaosz/article/details/51398071

Tips:
如果觉得这篇博客对你有帮助或者喜欢博主的写作风格,就给博主留个言或者顶一下呗,鼓励博主创作出更多优质博客,Thank you.

1 0
原创粉丝点击