美文网首页Android学习—点滴积累
Error:java.lang.OutOfMemoryError

Error:java.lang.OutOfMemoryError

作者: Andr0 | 来源:发表于2017-05-02 17:44 被阅读575次
    • 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

    相关文章

      网友评论

        本文标题:Error:java.lang.OutOfMemoryError

        本文链接:https://www.haomeiwen.com/subject/cafhtxtx.html