本文主要是介绍Android开发中遇到的各类问题汇总,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
Q1:
Error:The number of method references in a .dex file cannot exceed 64K.
Learn how to resolve this issue at https://developer.android.com/tools/building/multidex.html
应用中的Dex 文件方法数超过了最大值65536的上限,简单来说,应用爆棚了.
参考:
https://isming.me/2015/05/01/android-multi-dex/
http://www.jianshu.com/p/f68b0b070c31
http://blog.csdn.net/sjzx3142/article/details/51376601
http://www.cnblogs.com/zhaoyanjun/p/5390690.html
Q2:
Error:Execution failed for task ':AppNameAPP:transformClassesWithDexForDebug'.> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_101\bin\java.exe'' finished with non-zero exit value 2
这个应该很常见,导入的jar包重复
Q3:
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/home/jim/tools/jdk1.8.0_45/bin/java'' finished with non-zero exit value 3
参考:
https://stackoverflow.com/questions/31605291/gradle-finished-with-non-zero-exit-value-3
dexOptions {
javaMaxHeapSize "4g"
}
Q4
Error:java.lang.OutOfMemoryError: GC overhead limit exceededError:Execution failed for task ':AppNameAPP:transformClassesWithDexForDebug'.> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_101\bin\java.exe'' finished with non-zero exit value 3
咋一看是“OutOfMemoryError”顿时有点受精,不,是受惊了,明明内存这一块特意控制了怎么会内存溢出呢?
其实主要原因是:编译android遇到java虚拟机堆内存不够的问题
在一些规模稍大的应用中,Java虚拟机(JVM)的内存设置尤为重要,想在项目中取得好的效率,GC(垃圾回收)的设置是第一步。
参考:
http://www.jianshu.com/p/bcd3b1f512e7
http://blog.csdn.net/hikvision_java_gyh/article/details/38435855
http://www.cnblogs.com/wanqieddy/archive/2013/01/28/2880175.html
http://www.cnblogs.com/hucn/p/3572384.html在Stack OverFlow找到了解决方案:
org.gradle.jvmargs=-Xmx4096m -XX:MaxPermSize=4096m -XX:+HeapDumpOnOutOfMemoryError
这篇关于Android开发中遇到的各类问题汇总的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!