如果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
参考:
https://code.google.com/p/android/issues/detail?id=197231