eclipse 构建 Cordova PhoneGap 时出现 VM 错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/30384375/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 22:39:11  来源:igfitidea点击:

VM error while Build Cordova PhoneGap

androideclipsecordovaphonegap-build

提问by GaneshKumar

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

我在尝试创建Cordova PhoneGap应用程序时遇到此错误,并在最后一步中使用 build 命令

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

回答by Changwang Zhang

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

您的系统无法为 jvm 提供足够的连续内存空间并导致问题。

Here is what works for me:

以下是对我有用的方法:

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

添加一个环境变量GRADLE_OPTS的值为-Dorg.gradle.jvmargs=-Xmx512m

You can use -Xmx1gif you have more memory space available.

您可以使用-Xmx1g,如果您有更多的可用内存空间。

回答by gattsbr

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

Close Visual Studio- 至少在我的情况下这是问题。

and/or any other memory intensive program.

和/或任何其他内存密集型程序。

回答by hvaughan3

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

JAVA_HOME默认为 x86 版本。JAVA_HOME在 System env 变量中添加一个新变量并将其指向 x64 版本对我有用。这是我最终选择的路径:

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

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

回答by Battlecity

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

即使我使用了 2 个演出(-Dorg.gradle.jvmargs=-Xmx2048m),我也遇到了这个错误,但是当我将 JAVA_HOME 更改为 64 位 JDK 目录时它开始工作。使用更高版本的 Java 也可能有所帮助(1.8+)。

回答by user5470846

Change argument -Xmx20484mto 1024at line:

将参数更改-Xmx20484m1024at 行:

args.push('-Dorg.gradle.jvmargs=-Xmx1024m'); 

in your project file

在您的项目文件中

platforms\android\cordova\lib\builders\GradleBuilder.js

平台\android\cordova\lib\builders\GradleBuilder.js

. It's work for me

. 这对我有用

https://forum.ionicframework.com/t/build-failed-unable-start-the-daemon-process/72171

https://forum.ionicframework.com/t/build-failed-unable-start-the-daemon-process/72171

It work for me in eclipce phonegap plugin

它在 eclipce phonegap 插件中对我有用

回答by superthomas

just solved this problem in windows 8.1 and windows 7. Here is what I did:

刚刚在 windows 8.1 和 windows 7 中解决了这个问题。这是我所做的:

  1. Uninstall everything that is java related in your Programs and Features in control panel
  2. 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
  3. Download and install the latest Java SDK from here
  4. After all you are done go to cmd(run as admin) and try to build again
  1. 在控制面板中卸载程序和功能中与 Java 相关的所有内容
  2. 检查以下目录并删除 java 文件夹:c:\users\\AppData\Local\Oracle b. c:\users\\AppData\LocalLow\Oracle c. c:\Program Files\Java d. C:\Program Files (x86)\Java C:\ProgramData\Oracle **重要提示:只有在成功卸载控制面板 > 程序和功能中的所有 java 条目后才能删除此文件夹
  3. 这里下载并安装最新的 Java SDK
  4. 完成所有操作后,转到 cmd(以管理员身份运行)并尝试再次构建

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.

结论:据我所知,我的机器上没有正确配置/安装 java。所以一切都干净安装解决了我的问题。

回答by rNix

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

我也有同样的问题。尝试以管理权限运行命令行。

回答by Shriganesh Kolhe

Run the following command in CLI with admin right.

在 CLI 中以管理员权限运行以下命令。

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

这发生在我有很多内存但内存 ulimits 较低的机器上。Java 决定分配一个大堆,因为它检测到机器中的 ram,但由于 ulimits 不允许分配它。

回答by Piya Poonsawat

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

在环境变量中,添加一个_JAVA_OPTIONS值为的系统变量-Xmx512M

回答by SabaS

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

安装 64 位版本的 Java JDK 并将 JAVA_HOME 指向安装字典。