Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VM error while Build Cordova PhoneGap

I got this error while i tried to create a Cordova PhoneGap application, and in the final step while I use the build command

cordova build android

I got this error:

enter image description here

Error

    
D:\rmapp>cordova run android
Running command: D:\rmapp\platforms\android\cordova\run.bat
ANDROID_HOME=D:\Android\sdk
JAVA_HOME=C:\Program Files (x86)\Java\jdk1.7.0_71
WARNING : No target specified, deploying to device '192.168.56.100:5555'.
Running: D:\rmapp\platforms\android\gradlew cdvBuildDebug -b D:\rmapp\platform
s\android\build.gradle -PcdvBuildArch=x86 -Dorg.gradle.daemon=true

FAILURE: Build failed with an exception.

* What went wrong:
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
.2.1/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.


* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug
option to get more log output.

D:\rmapp\platforms\android\cordova\node_modules\q\q.js:126
                    throw e;
                          ^
Error code 1 for command: cmd with args: /s /c "D:\rmapp\platforms\android\grad
lew cdvBuildDebug -b D:\rmapp\platforms\android\build.gradle -PcdvBuildArch=x86
 -Dorg.gradle.daemon=true"
ERROR running one or more of the platforms: Error: D:\rmapp\platforms\android\c
ordova\run.bat: Command failed with exit code 1
You may not have the required environment or OS to run this project

like image 860
GK_ Avatar asked May 21 '15 21:05

GK_


3 Answers

Your system can not provide enough continuous memory space for the jvm and causes the problem.

Here is what works for me:

Add an environment variable GRADLE_OPTS with the value of -Dorg.gradle.jvmargs=-Xmx512m

You can use -Xmx1g if you have more memory space available.

like image 192
Changwang Zhang Avatar answered Nov 16 '22 18:11

Changwang Zhang


Close Visual Studio -- at least this was the problem in my case.

and/or any other memory intensive program.

like image 8
gattsbr Avatar answered Nov 16 '22 18:11

gattsbr


My JAVA_HOME was defaulting to the x86 version. Adding a new JAVA_HOME variable in the System env variable and pointing it to the x64 version worked for me. This was the path I ended up with:

C:\Program Files\Java\jdk1.8.0_162

like image 5
hvaughan3 Avatar answered Nov 16 '22 18:11

hvaughan3