Android transformClassesWithDexForAdh5Debug 的解决方法

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 an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate 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.

发布了34 篇原创文章 · 获赞 338 · 访问量 90万+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章