21

I'm getting error: "Gradle project sync failed. Basic functionality (e.g. eiditing) will not work properly."

And Error Log:

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/1.10/userguide/gradle_daemon.html 
Please read below 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.

I was trying to delete .gradle folder as I read here. This worked yesterday but today when I started Android Studio the error showed again and deleting .gradle folder doesn't help.

I realy don't know what to do.

Does anyone have any suggestions?

1
  • Install Jdk 1.8 and change project jdk to 1.8 by going to File >> Project Structure >> sdk location >> Jdk location in android studio
    – Lucky Rana
    Jun 22, 2016 at 5:43

11 Answers 11

73

Just a blind guess: try to add something like this to your gradle.properties file in the project:

org.gradle.jvmargs=-Xmx512m -XX:MaxPermSize=512m
3
  • In my project i don't have gradle.properties file. In that case I have follow @Jagadish's answer. it works for me. May 6, 2015 at 5:06
  • Grate work, @Prizoff !!! I have changed it to org.gradle.jvmargs=-Xmx1024m -XX:MaxPermSize=512m before looked for your answer and it not helped me at all. But Xmx512m worked for me too. Thanks
    – AEMLoviji
    Sep 2, 2015 at 7:32
  • UPDATED: I just add: "org.gradle.jvmargs=-Xmx512m" without " -XX:MaxPermSize=512m" and It Works.
    – Joe Kdw
    Oct 13, 2016 at 11:26
13

Same issue solve in Android studio by

File -> Settings -> Compiler (Gradle-based Android Projects)

Change the "**VM options**" to 
-Xmx512m -XX:MaxPermSize=512m

It worked for me .

0
5

The only way I've been able to fix this when it happens is by doing

./gradlew clean 

and

./gradlew --refresh-dependencies

and then restarting Android Studio.

If that doesn't work I usually resort to reimporting the project.

0
4

I had the Same Issue, and Searched for almost 4 Days but can't able to solve the problem.

But at Last I can able to solve the problem, and for that please follow the steps.

Step 1: Check Your Java Version.

Step 2: If It is 1.7 then Download the New Version i.e JDK 1.8

Step 3: Install JDK 1.8

Step 4: Change the Java Version of Android Studio to 1.8 and the problem solved...

It Worked for me.

0
1

changing compile setting to this worked for me

enter image description here

1

I was getting the same error in version 2.2.3,So I downloaded the latest Android Studio version 2.3.3, even in the latest version, I was getting the same error, below is my solution :-

  1. Download the latest version of Android Studio from the official site.

  2. In File>Project Structure>SDK Location, JDK Location should refer a 64-bit JDK ex. C:\Program Files\Java\jdk1.8.0_131, even after this, error was not fixed completely.

  3. I checked the project structure, In the File>Project Structure>Project , the Android Plugin version was still 2.2.3, I changed it to 2.3.3 and the build is successful and everything is working smoothly.

0

This one worked for me.

  1. Close the Android Studio
  2. Delete .gradle folder from c:\users\{username}\.gradle
  3. Open the Android Studio
  4. Clean Project
  5. Rebuild Project
  6. Sync Project with gradle files. See screen shot

    Cheers!

0

Check if the gradle path in File -> Settings -> Build, Execution -> Gradle is correct. I had incorrect path to local gradle distribution there.

0

None of these worked for me, so this is how I eventually solved my problem:

  • In the top-level build build.gradle file, remove 'classpath 'com.android.tools.build:gradle:some version number'
  • sync your project and make sure your gradle location is pointing at the correct directory
-1

Updating Java and the problem is solved!

Control panel > Java > Update Now
0
-1

I was in that situation, finding near no solution; finally I realized that my firewall was blocking java executable from opening ports/connecting. Try adding a firewall exception for the Java executable. This solved the problem for me.

1
  • This may help for network problems but not for the stated "too small heap". Mar 4, 2016 at 7:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.