Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How set Gradle JVM settings in Android Studio 1.3

Starting with version 1.3, Android Studio will no longer support IDE-specific Gradle JVM argument settings. Gradle JVM settings need to be set in gradle.properties files. This change is necessary to keep build output consistent, regardless of where the build is executed (IDE, command line or CI server.) If your project is using IDE-specific Gradle JVM arguments, Android Studio will, on project sync, help you copy those settings to your project's gradle.properties file. The "Gradle VM options" text field in the "Gradle" settings page has been removed as well.

I'm getting error:

Error:Unable to start the daemon process.
This problem might be caused by incorrect configuration of the daemon.
For example, an unrecognized jvm option is used.
Please refer to the user guide chapter on the daemon at     http://gradle.org/docs/2.4/userguide/gradle_daemon.html
Please read the following process output to find out more:
-----------------------
Error occurred during initialization of VM
Could not reserve enough space for object heap
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.  

My gradle.properties files

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

org.gradle.parallel=true
like image 357
gadfil Avatar asked Jun 10 '15 18:06

gadfil


People also ask

How do I pass JVM options to Gradle?

Try to use ./gradlew -Dorg. gradle. jvmargs=-Xmx16g wrapper , pay attention on -D , this marks the property to be passed to gradle and jvm. Using -P a property is passed as gradle project property.

Where is Gradle settings in Android Studio?

Open your project in Android Studio and select File > Settings... > Build, Execution, Deployment > Build Tools > Gradle (Android Studio > Preferences... > Build, Execution, Deployment > Build Tools > Gradle on a Mac).

Which JDK version should I use for Android studio?

A copy of the latest OpenJDK comes bundled with Android Studio 2.2 and higher, and this is the JDK version we recommend you use for your Android projects.


1 Answers

Try changing your jvmargs to the following

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

Or something smaller -Xmx512m as your system does not have enough memory to create the object heap and thus the jvm.

You can also add the following option too:

 org.gradle.daemon=true

For those on macosx I like to add the following

-Djava.awt.headless=true
like image 181
Ray Hunter Avatar answered Sep 23 '22 19:09

Ray Hunter