离子android构建 - 没有足够的内存来启动jvm

aks*_*ppy 12 android hybrid-mobile-app ionic

当试图使用ionic和gradle创建一个android apk文件时,我收到一个错误

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:\test\platforms\android\cordova\node_modules\q\q.js:126
                    throw e;
                          ^
Error code 1 for command: cmd with args: /s /c "D:\test\platforms\android\gradle
w cdvBuildDebug -b D:\test\platforms\android\build.gradle -Dorg.gradle.daemon=tr
ue"
ERROR building one of the platforms: Error: D:\test\platforms\android\cordova\bu
ild.bat: Command failed with exit code 1
You may not have the required environment or OS to build this project
Error: D:\test\platforms\android\cordova\build.bat: Command failed with exit cod
e 1
    at ChildProcess.whenDone (C:\Users\9923\AppData\Roaming\npm\node_modules\cor
dova\node_modules\cordova-lib\src\cordova\superspawn.js:131:23)
    at ChildProcess.emit (events.js:110:17)
    at maybeClose (child_process.js:1015:16)
    at Process.ChildProcess._handle.onexit (child_process.js:1087:5)
Run Code Online (Sandbox Code Playgroud)

我试图在Windows 7桌面上执行此操作.我的Java内存设置如下.

D:\test>java -XX:+PrintFlagsFinal -version | findstr /i "HeapSize PermSize Threa
dStackSize"
     intx CompilerThreadStackSize                   = 0               {pd produc
t}
    uintx ErgoHeapSizeLimit                         = 0               {product}
    uintx HeapSizePerGCThread                       = 87241520        {product}
    uintx InitialHeapSize                          := 67108864        {product}
    uintx LargePageHeapSizeThreshold                = 134217728       {product}
    uintx MaxHeapSize                              := 1044381696      {product}
     intx ThreadStackSize                           = 0               {pd produc
t}
     intx VMThreadStackSize                         = 0               {pd produc
t}
java version "1.8.0_05"
Java(TM) SE Runtime Environment (build 1.8.0_05-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.5-b02, mixed mode)
Run Code Online (Sandbox Code Playgroud)

我尝试过设置-Xms-Xmx在很多地方,但系统无法启动它.我该如何解决这个问题?

我改变了

在我的电脑>属性>添加JAVA_OPTS Environment Variables
添加JAVA_OPTS在dx.bat在Android SDK中
添加JAVA_OPTS在build.bat内部应用程序文件夹
改变JAVA_OPTS在gradle.properties

请帮忙

Cha*_*ang 19

Barlrog30的解决方案对我不起作用,但启发了我.

这对我有用:

设置一个GRADLE_OPTS可以达到值的环境-Dorg.gradle.jvmargs=-Xmx512m

我在用:

Windows 7 64bit + Jdk 32bit + cordova 5.3.1
Run Code Online (Sandbox Code Playgroud)

  • 只是为了澄清一下,在Windows命令提示符下:设置GRADLE_OPTS = -Dorg.gradle.jvmargs = -Xmx512m (5认同)

aks*_*ppy 4

发现此问题是特定于环境的。发布答案只是为了帮助那些可能遇到这个不幸问题的人。

通过在64位Windows 7上安装32位JDK解决了该问题。

安装前

  1. 转到应用程序管理器删除所有 JRE 和 JDK 安装
  2. 删除与旧 Java 安装相关的所有环境变量
  3. 更新/删除 Path 变量中所有与 Java 相关的条目。(不要删除路径变量)
  4. 重新启动系统
  5. 安装下载的JDK
  6. 转到环境变量并添加所需的密钥
  7. 更新 Path 变量以包含 JDK bin 文件夹

我不知道为什么会发生这种情况,但问题已经解决。