1

I am trying to run my app on the emulator but when i try I am getting this error :

Error:Failed to complete Gradle execution.

Cause:
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     https://docs.gradle.org/2.10/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.

I looked on stack overflow for this exact problem other people had but nothing was helpful . Can someone help me ?

3 Answers3

1

Well, just read the error message:

Error occurred during initialization of VM

obviously.

Could not reserve enough space for object heap

Now thats a useful hint.

In combination with this:

For example, an unrecognized jvm option is used.

the error indicates, that you have set something incorrectly. Maybe you accidentaly changed the VM heap options for java.

Maybe this is a solution to your problem, it tells you how to change the heap size for androidstudio.

If this does not work, make sure you have the latest version of android JDK/JRE installed. Maybe it would be helpful if you told us what you already tried and some specs about your computer. If you only have 512MB RAM, changing the heapsize wont help that much ;)

Community
  • 1
  • 1
Hafnernuss
  • 2,659
  • 2
  • 29
  • 41
  • Seriously, then please post at least some hardware specs and what you have tried in addition to the thing i suggested. – Hafnernuss Jun 20 '16 at 21:34
  • propably you are using 32 Bit java on a 64 bit OS? Did the problem occur from one day to the next? – Hafnernuss Jun 20 '16 at 21:35
  • Yes I just download the newest version of android studio . I just downloaded the newest version of java like 3 mins ago and it still doesn't work . I tried changing the gradle file to a different android studio file and it didn't work –  Jun 20 '16 at 21:48
  • Im going to ask you one last time.. PLEASE, with lots of sugar and cream on top, please post some information about your machine. CPU, RAM, OS used (version).... – Hafnernuss Jun 20 '16 at 21:53
  • windows 7 32-bit i7 cpu RAM(4.00gb(2.92gb usable )) . Processor 2.13GHz –  Jun 20 '16 at 21:57
  • 3GB Ram is a bit.... sparse for android studio I hope you dont plan to run a AVD on this machine.... – Hafnernuss Jun 20 '16 at 22:01
  • I'm getting 61 errors . I fixed the problem but when I tried to run the app on the phone it says I have 61 errors –  Jun 20 '16 at 22:04
  • Then what did you do to fix the errors? What are the error messages? Are they code related? – Hafnernuss Jun 20 '16 at 22:04
  • it's not code related . It says that I have to increase the gradle daemon to more than 2048 mb but I can't find my daemon process –  Jun 20 '16 at 22:06
  • try adding: android { dexOptions { javaMaxHeapSize "2g" } to your build.gradle file – Hafnernuss Jun 20 '16 at 22:08
  • I'm still getting the same problems . 46 errors now –  Jun 20 '16 at 22:10
  • whats it this time? – Hafnernuss Jun 20 '16 at 22:16
  • The same gradle daemon to more than 2048 mb –  Jun 20 '16 at 22:17
  • sorry, other than that, i do not know whats wrong. try cleaning the project and do a full rebuild – Hafnernuss Jun 20 '16 at 22:20
  • What file do I need to go in to change my daemon mb ? I am getting three files : daemon-5060.out , registry.bin , and registry.bin.lock –  Jun 20 '16 at 22:22
  • In daemon 2.5 I only have this file : registry.bin.lock –  Jun 20 '16 at 22:22
  • oh lord, no. in your project, you have build.gradle files. This are the ones that need to be changed. – Hafnernuss Jun 20 '16 at 22:24
  • But it says the daemon file –  Jun 20 '16 at 22:24
  • please, try what i posted. add those lines to the build.grade file – Hafnernuss Jun 20 '16 at 22:31
  • then im really out of ideas. sorry. – Hafnernuss Jun 20 '16 at 22:44
1

I had this same error several times yesterday. What I did is turn android studio off...and remove the gradle and .gradle file from my project file (the one I was working on through my user directory) and then...I turned on Android studio, tried to run my project and it gave me a new error that I need some type of version of gradle. I then turned off android studio and went and re-added the gradle and .gradle files to my project file, turned on android studio and ran the project. That fixed it. I am not sure if it will work for you but you can try it.

Sambulo Senda
  • 1,388
  • 1
  • 14
  • 19
1

In gradle properties I added this code and it worked for me "org.gradle.jvmargs=-Xmx512m -XX:MaxPermSize=512m"

Deepak S
  • 183
  • 1
  • 10