Android Studio2.0遇到Error:java.lang.OutOfMemoryError: GC overhead limit exceeded

http://androidren.com/index.php?qa=384&qa_1=android-studio2-0%E9%81%87%E5%88%B0error-outofmemoryerror-overhead-exceeded

如果Android Studio编译或运行遇到下面错误:
Error:this warning is that reflective operations on this class will incorrectly
Error:indicate that it is *not* an inner class.
Error:UNEXPECTED TOP-LEVEL ERROR:
Error:java.lang.OutOfMemoryError: GC overhead limit exceeded
Error: at com.android.dx.ssa.SetFactory.makeLivenessSet(SetFactory.java:91)
Error: at com.android.dx.ssa.SsaBasicBlock.addLiveIn(SsaBasicBlock.java:806)
Error: at com.android.dx.ssa.back.LivenessAnalyzer.liveInAtStatement(LivenessAnalyzer.java:218)
Error: at com.android.dx.ssa.back.LivenessAnalyzer.handleTailRecursion(LivenessAnalyzer.java:131)
Error: at com.android.dx.ssa.back.LivenessAnalyzer.run(LivenessAnalyzer.java:188)
Error: at com.android.dx.ssa.back.LivenessAnalyzer.constructInterferenceGraph(LivenessAnalyzer.java:93)
Error: at com.android.dx.ssa.back.SsaToRop.<init>(SsaToRop.java:82)
Error: at com.android.dx.ssa.back.SsaToRop.convertToRopMethod(SsaToRop.java:69)
Error: at com.android.dx.ssa.Optimizer.optimize(Optimizer.java:101)
Error: at com.android.dx.ssa.Optimizer.optimize(Optimizer.java:72)
Error: at com.android.dx.dex.cf.CfTranslator.processMethods(CfTranslator.java:297)
Error: at com.android.dx.dex.cf.CfTranslator.translate0(CfTranslator.java:137)
Error: at com.android.dx.dex.cf.CfTranslator.translate(CfTranslator.java:93)
Error: at com.android.dx.command.dexer.Main.processClass(Main.java:729)
Error: at com.android.dx.command.dexer.Main.processFileBytes(Main.java:673)
Error: at com.android.dx.command.dexer.Main.access$300(Main.java:82)
Error: at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:602)
Error: at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:170)
Error: at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:229)
Error: at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:158)
Error: at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:229)
Error: at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:158)
Error: at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:229)
Error: at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:158)
Error: at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:229)
Error: at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:158)
Error: at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:229)
Error: at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:158)
Error: at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:229)
Error: at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:158)
Error: at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:229)
Error: at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:158)
Error:Execution failed for task ':trunk:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: java.lang.RuntimeException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/bin/java'' finished with non-zero exit value 3
Information:BUILD FAILED
 
解决方法:
在build.gradle中添加:

dexOptions {

     incremental true

    javaMaxHeapSize "4g"

}

如果添加了不好使,那么修改 'gradle.properties' :

org.gradle.jvmargs=-Xmx4096m -XX:MaxPermSize=4096m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

还有关闭选项也可以试试:-XX:-UseGCOverheadLimit

参考:

http://stackoverflow.com/questions/27164452/how-to-solve-java-lang-outofmemoryerror-gc-overhead-limit-exceeded-error-in-and

https://code.google.com/p/android/issues/detail?id=197231

http://stackoverflow.com/questions/27367071/android-studio-1-0-failing-build-at-dexdebug-or-dexrelease



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值