Android Studio Google JAR file causing GC overhead limit exceeded error

I think there’s a separate way to raise the heap limit of the dexing operation. Add this to your android closure in your build.gradle file:

dexOptions {
    javaMaxHeapSize "4g"

and see if that helps.

(idea courtesy of this answer from Scott Barta)

In my case, to increase the heap-size looks like this:

Using Android Studio 1.1.0

android {
    dexOptions {
        incremental true
        javaMaxHeapSize "2048M"

Put the above code in your Build.gradle file.

This new issue is caused by the latest version of Android.

Go to your project root folder, open, and add the following options:


org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8



Then add these changes in your build.gradle file:

dexOptions {
        incremental = true
        preDexLibraries = false
        javaMaxHeapSize "4g" // 2g should be also OK

Leave a Comment