How do I fix java.lang.OutOfMemoryError: Java heap space when compiling my Android project?
I get this after I upgraded to version 1 of Android Studio.
I had a similar issue on Android Studio 2.3.3. APK packaging would fail saying Java heap space when building from Android Studio and trying to process a 300MB .so library. In my case two things were needed to fix it. Your build.gradle should contain something like that:
android {
dexOptions {
javaMaxHeapSize "4G"
}
}
At the root of your project you need to have a file named gradle.properties containing the following:
# That's needed for java to be able the create the APK with our 300MB native library
# Basically we grant java a 4GB heap.
org.gradle.jvmargs=-Xmx4608m