【问题标题】:ionic cordova could not reserve enough space for 2097152KB object heapionic cordova 无法为 2097152KB 对象堆保留足够的空间
【发布时间】:2018-02-11 12:46:38
【问题描述】:

我尝试为 Android 生成一个发布版本,但在命令之后:“ionic cordova build --release android”我遇到了异常:

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 https://docs.gradle.org/4.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 2097152KB object heap


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

* Get more help at https://help.gradle.org
(node:7276) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: cmd: Command failed with exit code 1 Error output:
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 https://docs.gradle.org/4.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 2097152KB object heap


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

* Get more help at https://help.gradle.org
(node:7276) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

我试过这个: 转到开始->控制面板->系统->高级(选项卡)->环境变量->系统变量->新建: 变量名:_JAVA_OPTIONS 变量值:-Xmx512M GRADLE_OPTS:-Xmx2048M 还有这个:所以你必须有 Android Api 23 才能让这个命令工作。 安装 Api 23 等后,Daemon 进程的错误将得到解决 构建工具并运行命令 我已经加载了最新版本的 jdk/jre(64 位) 我尝试用这个来制作一个 gradle.properties:org.gradle.jvmargs=-Xmx1024m -XX:MaxPermSize=256m 但是这个异常还是会出现。请帮忙

【问题讨论】:

    标签: java android cordova ionic-framework


    【解决方案1】:

    SO POST 中查看答案。您可以在环境变量下可用的系统变量中设置_JAVA_OPTIONS。

    另一种选择是从 32 位 JDK 切换到 64 位 JDK。希望对你有帮助

    【讨论】:

    • 正如我所写,我已经尝试过这种方式:尝试过:1._JAVA_OPTIONS:-Xmx512M 2.GRADLE_OPTS:-Xmx2048M 3.Android Api 23 4.jdk/jre(64 -bit) 5. gradle.properties with this:org.gradle.jvmargs=-Xmx1024m -XX:MaxPermSize=256m
    • @fel 抱歉,我忽略了它。哪个版本的科尔多瓦?
    • 节点版本:v8.9.4 Cordova 版本:8.0.0
    • @fel 你有添加任何插件吗?你在cordova更新后删除并添加了android平台吗?
    • 是的。切换到 64 位 JDK 也对我有用。类似的线程,类似的解决方案可以在这里找到stackoverflow.com/questions/41216921/…
    猜你喜欢
    • 2017-05-04
    • 1970-01-01
    • 2021-09-22
    • 2019-04-12
    • 2021-11-27
    • 2014-02-28
    • 2013-01-17
    相关资源
    最近更新 更多