Skip to content Skip to sidebar Skip to footer

Jvmargs=-xmx2048m Dex In Process For Cordova

cordova build tells me the following To run dex in process, the Gradle daemon needs a larger heap. It currently has approximately 910 MB. For faster builds, increase the maxim

Solution 1:

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"
  }
}

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'));
}

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

Solution 2:

Try setting this environment variable before starting the gradle daemon

export GRADLE_OPTS=-Xmx2g

edit

Wait.. why can you not just do what the message says?

set org.gradle.jvmargs=-Xmx2048M in the project gradle.properties

Post a Comment for "Jvmargs=-xmx2048m Dex In Process For Cordova"