bug: Android Espresso - java.lang.OutOfMemoryError: GC overhead limit exceeded
解决:
dexOptions {
javaMaxHeapSize "4g"
}
dexOptions javaMaxHeapSize
在Gradle 进行dex的可能会遇到内存不够用的情况,错误信息大概是java.lang.OutOfMemoryError: GC overhead limit exceeded。这个时候只需要配置dexOptions的javaMaxHeapSize大小即可,我这里配置4g
转自http://www.lai18.com/content/9434022.html?from=cancel
最近开发过程中经常会碰到这样的问题,度娘google不少,发现能真正解决的没几个,有些人说jar冲突,有些说是内存配置过小,有些说是jdk版本不对,各种各种的回答都有,但没办法解决这问题,具体会报如下错误:‘java.lang.OutOfMemoryError: GC overhead limit exceeded
at java.util.Arrays.copyOf(Arrays.java:2219)
at java.util.ArrayList.toArray(ArrayList.java:358)
at java.util.ArrayList.(ArrayList.java:164)
at com.android.dx.ssa.SsaMethod.getUseListCopy(SsaMethod.java:660)
at com.android.dx.ssa.ConstCollector.updateConstUses(ConstCollector.java:333)
at com.android.dx.ssa.ConstCollector.run(ConstCollector.java:147)
at com.android.dx.ssa.ConstCollector.process(ConstCollector.java:75)
at com.android.dx.ssa.Optimizer.runSsaFormSteps(Optimizer.java:181)
at com.android.dx.ssa.Optimizer.optimize(Optimizer.java:99)
at com.android.dx.ssa.Optimizer.optimize(Optimizer.java:72)
at com.android.dx.dex.cf.CfTranslator.processMethods(CfTranslator.java:303)
at com.android.dx.dex.cf.CfTranslator.translate0(CfTranslator.java:139)
at com.android.dx.dex.cf.CfTranslator.translate(CfTranslator.java:94)
at com.android.dx.command.dexer.Main.processClass(Main.java:682)
at com.android.dx.command.dexer.Main.processFileBytes(Main.java:634)
at com.android.dx.command.dexer.Main.access600(Main.java:78)atcom.android.dx.command.dexer.Main600(Main.java:78)
at com.android.dx.command.dexer.Main1.processFileBytes(Main.java:572)
at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
at com.android.dx.command.dexer.Main.processOne(Main.java:596)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:498)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:264)
at com.android.dx.command.dexer.Main.run(Main.java:230)
at com.android.dx.command.dexer.Main.main(Main.java:199)
at com.android.dx.command.Main.main(Main.java:103)
:Project:dexFlavorEnterpriseDebug FAILED
一碰到这样就脑袋大,错误无从下手,终于在google有人回答了这个,在build.gradle中的android{}添加如下脚本就可以顺利编译了
dexOptions {
incremental true
javaMaxHeapSize “4g”
}