Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Increase the Memory that's available to gradle

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?

like image 862
X09 Avatar asked Apr 28 '16 11:04

X09


People also ask

How do I give more memory to Gradle?

For faster builds, increase the maximum heap size for the Gradle daemon to more than 2048 MB. To do this set org. gradle. jvmargs=-Xmx2048M in the project gradle.

How much RAM should I allocate to Gradle?

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).


2 Answers

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.

like image 51
Roger Whitney Avatar answered Sep 27 '22 19:09

Roger Whitney


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

android{
     //....
     dexOptions {
        javaMaxHeapSize "2g"
    }
}
like image 38
W.K.S Avatar answered Sep 27 '22 19:09

W.K.S