问题如下
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
D:\Levana2\MyApp>cordova build
Checking Java JDK and Android SDK versions
ANDROID_SDK_ROOT=undefined (recommended setting)
ANDROID_HOME=C:\Users\levana.xue\AppData\Local\Android\Sdk (DEPRECATED)
Using Android SDK: C:\Users\levana.xue\AppData\Local\Android\Sdk
Starting a Gradle Daemon (subsequent builds will be faster)

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 Manual chapter on the daemon at https://docs.gradle.org/6.6.1/userguide/gradle_daemon.html
Process command line: D:\Levana.Xue\develop-tool\java-jdk\openjdk-8u41-b04-windows-i586-14_jan_2020\java-se-8u41-ri\bin\java.exe -Xmx2048m -Dfile.encoding=GBK -Duser.country=CN -Duser.language=zh -Duser.variant -cp D:\Levana.Xue\develop-tool\android-gradle\gradle-6.6.1\lib\gradle-launcher-6.6.1.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 6.6.1
Please read the following process output to find out more:
-----------------------
Error occurred during initialization of VM
Could not reserve enough space for 2097152KB object heap


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

* Get more help at https://help.gradle.org
Command failed with exit code 1: D:\Levana.Xue\develop-tool\android-gradle\gradle-6.6.1\bin\gradle.BAT -p D:\Levana2\MyApp\platforms\android wrapper -b D:\Levana2\MyApp\platforms\android\wrapper.gradle

原因

由于内存不够导致

解决方案

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.

link:https://stackoverflow.com/questions/30384375/vm-error-while-build-cordova-phonegap