如何解决离子构建错误“java heap space"? [英] How to solve the ionic build error "java heap space"?

查看:36
本文介绍了如何解决离子构建错误“java heap space"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个离子项目.该应用程序之前已成功构建并在我的 android 手机中运行.但是突然有一天,当我运行命令ionic cordova run android"时,我收到如下构建错误:

I have a ionic project. The app was build and run in my android phone successfully before. But suddenly from someday, when I run command "ionic cordova run android" I get the build error as below:

任务 ':transformClassesWithDexForDebug' 执行失败.com.android.build.api.transform.TransformException:com.android.ide.common.process.ProcessException:java.util.concurrent.ExecutionException:java.lang.OutOfMemoryError:Java 堆空间

Execution failed for task ':transformClassesWithDexForDebug'. com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: Java heap space

我尝试过cordova clean"来同步cordova插件.但它不起作用..

I have tried "cordova clean" to synchronise the cordova plugin. But it doesn't work..

如何解决这个问题?

推荐答案

在你的项目根目录下打开 gradle.properties 并将下面的行添加/修改到

Open gradle.properties under your project root directory and add/modify below line to

org.gradle.jvmargs=-Xmx3536m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError

指定用于守护进程的 JVM 参数.该设置对于调整内存设置特别有用.如果这仍然不能满足您的要求,请将 -Xmx3536m 更改为更大的值.

Specifies the JVM arguments used for the daemon process. The setting is particularly useful for tweaking memory settings. Change -Xmx3536m to a larger value if this still does not meet your requirement.

并且,修改您的模块级别 build.gradle

android {
    ...
    dexOptions {
        javaMaxHeapSize "2g"
    }
    ...
}

这篇关于如何解决离子构建错误“java heap space"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆