如何解决离子生成错误"java堆空间"? [英] How to solve the ionic build error "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堆空间"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!