Home » Android » android – How to Increase the Memory that's available to gradle

android – How to Increase the Memory that's available to gradle

Posted by: admin June 15, 2020 Leave a comment


In the official post detailing the features of the stable release of Android Studio 2.1, I came across this:

We are also speeding up build times by using in-process dex, which converts class files to dex files within the Gradle daemon process. This avoids the costly processing operation of creating separate dex processes. To use this feature, you will need to increase the amount of memory available to the Gradle daemon to at least 2GB (1 GB is the default).

Please, how can I increase the memory that’s available to Gradle?

How to&Answers:

In your app’s build.gradle file, add the following:

     dexOptions {
        javaMaxHeapSize "2g"


In Android Studio 2.1 open your gradle.properties file. Find the line

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

Uncomment the line. Gradle was faster after I did this.


I have not try this but it should works:

In graddle.build file:

apply plugin: 'java'

compileJava {
    //raise heap
    options.fork = 'true'
    options.forkOptions.with {
        memoryMaximumSize = '2048m'

If it does not work in Windows try to add it to a new file gradle.properties next to gradle.build

References: http://www.gubatron.com/blog/2014/07/29/solved-gradle-how-to-increase-the-java-compilers-available-heap-memory/

I hope it helps you