VM error while Build Cordova PhoneGap - android

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:
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

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.

Close Visual Studio -- at least this was the problem in my case.
and/or any other memory intensive program.

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

I had the same problem too. Try to run command line with administrative privileges.

just solved this problem in windows 8.1 and windows 7. Here is what I did:
Uninstall everything that is java related in your Programs and Features in control panel
check the following directory and delete the java folders:
a. c:\users\\AppData\Local\Oracle
b. c:\users\\AppData\LocalLow\Oracle
c. c:\Program Files\Java
d. C:\Program Files (x86)\Java
e. C:\ProgramData\Oracle
**IMPORTANT: only delete this folders after successfully uninstalling all java entries in control panel > Programs and Features
Download and install the latest Java SDK from here
After all you are done go to cmd(run as admin) and try to build again
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.

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+).

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

In Environment variables, add a system variable _JAVA_OPTIONS having the value -Xmx512M.

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.

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.

This error happens to me from time to time. I fix this by running the program "SDK Manager" in ANDROID_HOME folder.

I got this error because I didn't have a 32-bit JDK installed. Installed that, restarted and that fixed it.

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

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.

Install 64bit version of Java JDK and point JAVA_HOME to the install dictionary.

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

You need to allocate memory by setting two environment variables:
_JAVA_OPTIONS with value -Xmx2048M, to set up how much memory Java uses
GRADLE_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.

Related

getting error create new project in android studio

hello guys i updated my android studio 4.0 to 4.1
getting error after updating android studio build.gradle. i tried completely uninstall android studio but didn't worked again
log
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 Manual chapter on the daemon at https://docs.gradle.org/6.5/userguide/gradle_daemon.html
Process command line: C:\Program Files\Android\Android Studio\jre\bin\java.exe -XX:MaxPermSize=512m -Xmx2048m -Dfile.encoding=windows-1252 -Duser.country=GB -Duser.language=en -Duser.variant -cp C:\Users\Onur\.gradle\wrapper\dists\gradle-6.5-bin\6nifqtx7604sqp1q6g8wikw7p\gradle-6.5\lib\gradle-launcher-6.5.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 6.5
Please read the following process output to find out more:
-----------------------
Error occurred during initialization of VM
Could not reserve enough space for object heap
OpenJDK 64-Bit Server VM warning: ignoring option MaxPermSize=512m; support was removed in 8.0
-----------------------
Check the JVM arguments defined for the gradle process in:
- gradle.properties in project root directory
And memory usage %100. i tried exit android studio but java jdk exe uses computer ram %100 again
what's problem? someone help please? i want to use this project my website başvuru tarihi
Your computer probably does not have the right specifications to run android studio. You need more RAM and processing speed

Cmd/React Native can't detect my JAVA_HOME environment variables

I'm trying to create a React Native app for Android. I use bash from the command line in Windows 10. I browse to the location of my React Native project and then run "react-native run-android". But then I get an error like this:
$ react-native run-android
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 864 file(s) to forward-jetify. Using 4 workers...
info Starting JS server...
/bin/sh: 1: adb: not found
info Launching emulator...
error Failed to launch emulator. Reason: No emulators found as an output of `emulator -list-avds`.
warn Please launch an emulator manually or connect a device. Otherwise app may fail to launch.
info Installing the app...
ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.
error Failed to install the app. Make sure you have the Android development environment set up: https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
at checkExecSyncError (child_process.js:601:13)
at execFileSync (child_process.js:621:13)
at runOnAllDevices (/mnt/c/users/lenovo/documents/repositories/upself rn/upself/node_modules/#react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:94:39)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
TL;DR it tells me to set the environment variable for JAVA_HOME. AFAIK.
The problem is I've already set the JAVA_HOME since I installed the Windows 10 in my laptop which was months ago. I use JDK 12 and have developed few native Android app using Android Studio using this same laptop and never have I encountered any missing JAVA_HOME issue.
This is what I've tried to try to solve this issue:
Run the cmd as administrator
Set the JAVA_HOME to c:\Program Files\Java\jdk-12.0.2\ and the one in Android Studio default SDK location C:\Users\lenovo\AppData\Local\Android\Sdk. Both dont work.
Restart my laptop and cmd (done it multiple times but it still doesnt work).
Put a quotation mark between the path (found this in a stack overflow question).
I've read many questions in stack overflow but none of those works.
So, could anyone help me to solve this problem? Why is it unable to detect the environment path?
According to react native document, you should install just JDK 8 for running react native app
https://facebook.github.io/react-native/docs/getting-started
after installing java and set the environment variable, you must reboot your system.
https://www.thewindowsclub.com/set-java_home-in-windows-10

Error building Cordova apk

I'm new to Cordova, I can run my code in the browser using cordova run browser but I would like to turn it into an apk so I can run it on my phone and really test it.
The developer I am working with sends me apk all the time built from the same files whenever he has an update on the project, however when I want to make minor changes myself I can't create an apk to test them because it throws an error.
cordova build android --release
Error: Error code 1 for command: cmd with args: /s,/c,"X:\Websites\AppAndroid\platforms\android\gradlew cdvBuildDebug -b X:\Websites\AppAndroid\platforms\android\build.gradle -Dorg.gradle.daemon=true -Pandroid.useDeprecatedNdk=true"
It also says this but I can't make sense of it with my limited knowledge
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':transformClassesWithDexForDebug'.
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_79\bin\java.exe'' finished with non-zero exit value 1
I have tried some other solutions from other questions and YouTube videos such as setting my paths to JAVA and ANDROID_HOME but these didn't help my issue.
The read out also makes a suggestion, I tried this but it doesn't tell me anything extra in a log or fix the issue:
Try: Run with --stacktrace option to get the stack trace. Run with
--info or --debug option to get more log output.
UPDATE
I am wondering if it is my JAVA_HOME path.
That is set to 1.7.0_79
ANDROID_HOME=C:\User\Me\AppData\Local\Android\sdk JAVA_HOME=C:\Program
Files\java\jdk1.7.0_79
But when I do java -version I get this 1.8.0_121:
java version "1.8.0_121" Java(TM) SE Runtime Environment (build
1.8.0_121-b13) Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)
That's 2 different versions, but when I change JAVA_HOME in the environments window, it doesn't change JAVA_HOME that is displayed when I try to build the apk.
So I am unable to correct it to see if it fixes the error :\
I had configured JAVA_HOME wrong in my Environment Variables settings.
It was out of date compared to the Java I had installed.
Then when I tried to change it, I realised I didn't have the JDK installed, I only had JRE (Java Runtime Environment).
So I Googled javascript development kit download and was taken to the website and downloaded the JDK, then correctly set my paths in the Environment Variables settings to represent JDK not JRE.
I closed console and ran it all again and success, built!

nativescript sample projects fail with error Command ant failed with exit code 1

I went through the setup steps - on mac - but the sample nativescript projects all fail with the same error.
"Command ant failed with exit code 1"
Here is the log trace:
https://gist.github.com/getsetbro/c0225e8fc493d57b3f64
Other info
Android Studio on this mac run projects fine in emulators and connected devices
The same projects run in ios emulator without errors.
I installed JDK 8, never had version 7 on this system.
I see the following error in the logs.
Cannot run program "/Users/sb/Documents/Dev/nativescript/test_nativescript/platforms/android/${aapt}"
I might be wrong but it seems aapt tool is missing from your $PATH environment variable. If this is the case, try adding <ANDROID_SDK_ROOT>/tools to $PATH

Cordova add platform android error

Creating android project... Error:
C:\Users\user1.cordova\lib\npm_cache\cordova-android\3.6.4\package\bin\create.bat:
Command failed with exit code ENOENT at ChildProcess.whenDone
(C:\Users\user1\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\cordova\superspawn.js:135:23)
at ChildProcess.emit (events.js:95:17) at
Process.ChildProcess._handle.onexit (child_process.js:807:12)
The Path environment variable is set as :
C:\ProgramData\Oracle\Java\javapath;%SystemRoot%;%SystemRoot%\system32;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;D:\Program
Files\TortoiseSVN\bin;%JAVA_HOME%\bin;%ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools;%ANT_HOME%\bin;C:\Program
Files\nodejs\
where JAVA_HOME is :C:\Program Files\Java\jdk1.8.0_25 ANDROID_HOME is
: D:\Softwares\AndroidSDK\sdk\sdk ANDROID_SWT is:
D:\Softwares\AndroidSDK\sdk\sdk\tools\lib\x86_64 ANT_HOME: C:\Program
Files\apache-ant-1.9.4
I have tried with installing jdk 7 and 6 but still same error..
Can any one please help..
Finally the issue is resolved.. My ComSpec environment variable whose value is %SystemRoot%\system32\cmd.exe had a ";" at the end, which was causing this issue. I just removed ";" and yuppie.. it worked..
What actually happened here is that cmd command can not be found.
I got the same problem today on Windows 7, NodeJS 5.4, Cordova 5.4.1. cordova platform add android failed to work because of unknown issue. However, cordova -d platform add android actually showed some clues. cordova platform add android is a wrapper over the real command: cmd /s /c "..../create.bat" .... When you executed that command manually, you would know the underlying error: 'cmd' is not recognized as an internal or external command.
I have to change ComSpec environment variable from %SystemRoot%\system32\cmd.exe to %SystemRoot%\system32\cmd.exe;%SystemRoot%\system32 to make it work.
If it does not work, please add %SystemRoot%\system32 intp PATH as well
You've entered the wrong command.
Try this
cordova platform add android
fix is here (FOR WINDOWS ONLY)
I am facing the same problem of Build then i finally found out the solution.
SOLUTION
So You must have the Android Api 23 in order for this command to work.
Error of Daemon process will be solve after installing the Api 23 and extra build tools and run command
COMMAND : cordova build android --release
I am sure this fix would help you to solve the problem.
STEPS
1. First check the version of android through this COMMAND:
cordova platform help
2. Run the build command after installing the Api 23 and extra build tools.
3. If Even this not work then Try add the variable in the
Environment variables > System variables >
add _JAVA_OPTIONS and value = -Xmx512M
Then Run cordova build android --release
BUT FIRSTLY SET UP THE ENVIRONMENT VARIABLES
Environment Variable setup Image
android API 23
COPY FROM HERE
ENVIRONMENT VARIABLES:-
USER VARIABLES
PATH
C:\Ruby23\bin;C:\Users\kumar\AppData\Roaming\npm;C:\ANDROID_SDK\tools;%SystemRo
ot%\system32; %SystemRoot%; %SystemRoot%\System32\Wbem;
SYSTEM VARIABLES
ADD NAME AND VALUE
2.1 _JAVA_OPTIONS -Xmx512M
2.2 ANDROID_HOME C:\ANDROID_SDK
2.3 PATH ->
C:\ProgramFiles\Java\jdk1.8.0_60\bin;C:\ProgramFiles\nodejs;C:\Gradle\gradle-4.0\bin;C:\ANDROID_SDK\tools;%SystemRoot%\system32; %SystemRoot%; %SystemRoot%\System32\Wbem;%SystemRoot%\system32; %SystemRoot%; %SystemRoot%\System32\Wbem;

Categories

Resources