Reputation: 1222
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:
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
Upvotes: 17
Views: 17462
Reputation: 1489
I had a very similar problem that sometimes logged this JAVAC error and other times logged device connection problems or plugin not correctly installed. Ex:
Failed to run "javac -version"
Execute program failed with exit code 3221225794.
I successfully fixed it by running the following command that fixes all DLL problems on Windows, and then restarting the computer. From powershell, admin may be required:
sfc /scannow
Upvotes: 0
Reputation: 4349
You need to allocate memory by setting two environment variables:
_JAVA_OPTIONS
with value -Xmx2048M
, to set up how much memory Java usesGRADLE_OPTS
with value -Dorg.gradle.jvmargs=-Xmx2048m
, to set up how much memory Gradle uses (this can be specified by per project basis through [PROJECT PATH]\platforms\android\cordova\lib\builders\GradleBuilder.js
path, although by default it's setup to be 2GB atm)If cordova complains with Failed to run "javac -version"
change the memory in _JAVA_OPTIONS
for something lower.
Upvotes: -1
Reputation: 11105
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
Upvotes: 5
Reputation: 3772
Close Visual Studio
-- at least this was the problem in my case.
and/or any other memory intensive program.
Upvotes: 8
Reputation: 253
Run the following command in CLI with admin right.
>export _JAVA_OPTIONS="-Xmx256M"
This happens to me on machines with a lot of ram, but with lower memory ulimits. Java decides to allocate a big heap because it detects the ram in the machine, but it's not allowed to allocate it because of ulimits.
Upvotes: 2
Reputation: 11
Install 64bit version of Java JDK and point JAVA_HOME to the install dictionary.
Upvotes: 1
Reputation: 31
Change argument -Xmx20484m
to 1024
at line:
args.push('-Dorg.gradle.jvmargs=-Xmx1024m');
in your project file
platforms\android\cordova\lib\builders\GradleBuilder.js
. It's work for me
https://forum.ionicframework.com/t/build-failed-unable-start-the-daemon-process/72171
It work for me in eclipce phonegap plugin
Upvotes: 3
Reputation: 55
In Environment variables, add a system variable _JAVA_OPTIONS
having the value -Xmx512M
.
Upvotes: 2
Reputation: 77
I had had the same problem with my cordova project when I have installed the last version of JDK 1.8.0.121.
To solve the problem, I have uninstalled all my JDK versions (1.6, 1.7, 1.8..) and just installed the last version.
Upvotes: 1
Reputation: 1040
My solution was to just install the new Java SDK. I also had to change my JAVA_HOME
Path to point to that new SDK
Upvotes: 1
Reputation: 41
I got this error even if I used 2 gigs (-Dorg.gradle.jvmargs=-Xmx2048m), but it started to work when I changed JAVA_HOME to a 64-bit JDK directory. Using a higher version of Java might help also (1.8+).
Upvotes: 3
Reputation: 2623
I got this error because I didn't have a 32-bit JDK installed. Installed that, restarted and that fixed it.
Upvotes: 1
Reputation: 51
just solved this problem in windows 8.1 and windows 7. Here is what I did:
conclusion: from what I understand, I do not have java properly configured/installed in my machine. so a clean install of everything is what solved my problem.
Upvotes: 3
Reputation: 2483
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.
Upvotes: 20
Reputation: 123
This error happens to me from time to time. I fix this by running the program "SDK Manager" in ANDROID_HOME folder.
Upvotes: 1
Reputation: 27
I had the same problem while I was working on Cordova.
As mentioned in this post, it looks like the heap is not allocated and so the JVM isn't initialized.
Try to free your system cache and then try building the project.
Upvotes: 1
Reputation: 2567
I had the same problem too. Try to run command line with administrative privileges.
Upvotes: 3