Failed to sync Gradle project

2019-01-31 08:46发布

问题:

I am using Android studio 1.3.1 and getting this failed to sync Gradle project error :

Error:Unable to start the daemon process: could not reserve enough space for
object heap.            
Please assign more memory to Gradle in the project's gradle.properties file.
For example, the following line, in the gradle.properties file,
sets the  maximum Java heap size to 1,024 MB:
org.gradle.jvmargs=-Xmx1024m

my default org.gradle.jvmargs=-Xmx2048 and MaxPermSize=512m still it is showing me this error, can anybody tell me why I am getting this error?

回答1:

Method 1 :

For Android Studio 1.3 :

Step 1 : Open gradle.properties file in your Android Studio project.

Step 2 : Add this line at the end of the file

org.gradle.jvmargs=-XX\:MaxHeapSize\=256m -Xmx256m

Above methods seems to work but if in case it won't then do this

Method 2 :

Step 1 : Start Android studio and close any open project (File > Close Project).

Step 2 : On Welcome window, Go to Configure > Settings.

Step 3 : Go to Build, Execution, Deployment > Compiler

Step 4 : Change Build process heap size (Mbytes) to 1024 and Additional build process to VM Options to -Xmx512m.

Step 5 : Close or Restart Android Studio.



回答2:

try this way Open gradle.properties file.

add this line at the end:

org.gradle.jvmargs=-XX\:MaxHeapSize\=256m -Xmx256m

or

org.gradle.jvmargs=-XX\:MaxHeapSize\=512m -Xmx512m


回答3:

org.gradle.jvmargs=-XX\:MaxHeapSize\=512m -Xmx512m

Add this Line to the End of the gradle.properties file in Your project.

remember without '#'..