Error:java.lang.OutOfMemoryError: GC overhead limit exceeded

  • 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

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容