Android Studio Google JAR file causing GC overhead limit exceeded error
Android Studio 3.5.3
Find the Memory Settings (Cmd + Shift + A on Mac or click on Help and start typing "Memory Settings") under Preferences/ Settings and increase the IDE Heap Size and/ or the Daemon Heap Size to your satisfaction
This new issue is caused by the latest version of Android.
Go to your project root folder, open gradle.properties
, and add the following options:
org.gradle.daemon=true
org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
org.gradle.parallel=true
org.gradle.configureondemand=true
Then add these changes in your build.gradle
file:
dexOptions {
incremental = true
preDexLibraries = false
javaMaxHeapSize "4g" // 2g should be also OK
}
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.