jvmargs = -xmx2048m dex在过程中cordova [英] jvmargs=-xmx2048m dex in process for cordova

查看:2893
本文介绍了jvmargs = -xmx2048m dex在过程中cordova的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

cordova build告诉我以下

cordova build tells me the following


要运行dex,Gradle守护进程需要一个更大的堆。它
目前有大约910 MB。为了更快的构建,将Gradle守护程序的
最大堆大小增加到超过2048 MB。要做
,在项目
gradle.properties中设置org.gradle.jvmargs = -Xmx2048M。有关详细信息,请参阅
https://docs.gradle.org/current/userguide /build_environment.html

如何在cordova中将jvmargs设置为-xmx2084M?是可能通过config.xml还是我必须使用钩子?

how can I set the jvmargs to -xmx2084M in cordova? Is it possible through config.xml or do I have to use hooks?

感谢

Qiong

推荐答案

Qiong

你要在 platforms / android 文件夹中放置一个名为 build-extras.gradle 的文件。 Cordova将自动读取该文件,并为您加载配置。

您可以手动或通过钩子执行此操作。

Qiong
You nee to put a file named build-extras.gradlein your platforms/android folder. Cordova will read the file automatically and will load the configuration for you.
You can do this manually or by a hook. The problem of the first option is that if you erase your platform folder, the will be erased as well.

文件的内容指定了最大堆大小:

The content of the file specifies the maximum heap size:

android {
  dexOptions {
    javaMaxHeapSize "2048m"
  }
}

如果你想使用hook选项,内容应该是这样:

If you want to go with the hook option, the content of the should be like this:

#!/usr/bin/env node
'use strict';
var fs = require('fs');
var rootdir = process.argv[2];
if(fs.existsSync(rootdir + '/platforms/android')){
  console.log('Add build-extras.gradle');
  fs.createReadStream(rootdir + '/build-extras.gradle').pipe(fs.createWriteStream(rootdir + '/platforms/android/build-extras.gradle'));
}



您需要将文件放在 hooks / after_prepare / 文件夹。这将自动运行您的挂钩。

And you need to put the file on hooks/after_prepare/ folder. This will run your hook automatically.

这篇关于jvmargs = -xmx2048m dex在过程中cordova的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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