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

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容