- Android Studio编译报错 java.lang.OutOfMemoryError: GC overhead limit exceeded
Error:UNEXPECTED TOP-LEVEL ERROR:
Error:java.lang.OutOfMemoryError: GC overhead limit exceeded
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: Error while executing java process with main class com.android.dx.command.Main with arguments {--dex --num-threads=4 --multi-dex --main-dex-list E:\android\app\build\intermediates\multi-dex\debug\maindexlist.txt --output E:\android\app\build\intermediates\transforms\dex\debug\folders\1000\1f\main E:\android\app\build\intermediates\transforms\jarMerging\debug\jars\1\1f\combined.jar}
解决方法:
如果在整个工程中生效,则在module的 build.gradle中增加如下配置:
android {
..............
dexOptions {
incremental true
javaMaxHeapSize "4g"
}
...............
}
** 注意 在android {···dexOptions {··}·····}里 不要加错了**
如果只在单元测试的时候生效,则在build.gradle中增加如下配置:
android {
..............
testOptions {
android.dexOptions {
incremental true
javaMaxHeapSize "4g"
}
}
...............
}
**http://blog.leanote.com/post/freewalk/Markdown-%E8%AF%AD%E6%B3%95%E6%89%8B%E5%86%8C#title**
http://blog.leanote.com/post/freewalk/Markdown-%E8%AF%AD%E6%B3%95%E6%89%8B%E5%86%8C#title