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 參考鏈接
我是參考下面的博客解決問題的:
順便貼一下StackOverflow上關於這個問題的解答:
5 轉載請註明來自”梧桐那時雨”的博客:http://blog.csdn.net/fuchaosz/article/details/51398071
Tips:
如果覺得這篇博客對你有幫助或者喜歡博主的寫作風格,就給博主留個言或者頂一下唄,鼓勵博主創作出更多優質博客,Thank you.