Out of memory issue after updating buildToolsVersion '23.0.1' in Android studio Out of memory issue after updating buildToolsVersion '23.0.1' in Android studio android android

Out of memory issue after updating buildToolsVersion '23.0.1' in Android studio


The accepted answer works but I was confused for a bit about where to put the dexOptions in my build.gradle. We actually put it under the android section.

Here is example snippet:

android {    dexOptions {        javaMaxHeapSize "4g"    }    ......}


Actually for me worked a more complex solution, which combine all from above, plus enabling multidex in the build.gradle file for the module.

A. Add this line in the defaultConfig section to enable multiDex

// Enabling multidex support.multiDexEnabled true

B. Than set the dexOptions, like this:

dexOptions {    incremental true    javaMaxHeapSize "4G"}

C. After changing to multidex and setting the heap to 4g, an overflow error may occur which lead me to uncomment and modify the jvmargs line from gradle.properties file of the project, like:

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

The values may differ depending on your machine. You can also use double values.