JVM arguments gradle cannot be set in gradle.properties file for Android Studio 2.1.1

Jim Clermonts picture Jim Clermonts · May 30, 2016 · Viewed 14k times · Source

-Running Android 2.1.1 on Mac OS X

-App is not on Android phone.

content of gradle.properties file

org.gradle.jvmargs=-Xmx2048M

enter image description here

When hovering, the IDE indicates it is an unused property. It should also be dark blue instead of grey.

Output:

:MyProjectDirName:transformClassesWithInstantRunSlicerForDebug
:MyProjectDirName:transformClassesWithDexForDebug
To run dex in process, the Gradle daemon needs a larger heap.
It currently has approximately 910 MB.
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.properties.
For more information see   
https://docs.gradle.org/current/userguide/build_environment.html

The output of the compiler clearly indicates it discards the contents of the gradle.properties file.

contents build.gradle

android {
    dexOptions {
        javaMaxHeapSize "2g"
    }
}

Played with these settings aswell, no success:

enter image description here

Answer

Rubin Yoo picture Rubin Yoo · Jun 17, 2016

Try to add the 'org.gradle.daemon=true' inside gradle.properties file at

/Users/<username>/.gradle/ (Mac)

C:\Users\<username>\.gradle (Windows)

Answer based from

https://stackoverflow.com/a/33184794/1915831

https://stackoverflow.com/a/19500539/1915831