I am trying to set the maximum memory that DEX task can use in a gradle-based Android project, but can't find any option to do that.
My motivation to do this is because as dex
sometimes takes so much memory that my computer starts swapping and becomes completely unresponsive for some minutes (so I would rather see the task fail and then free some more resources and retry)
In my gradle.properties
I have org.gradle.jvmargs="-Xmx300m"
which limits the memory used by Gradle itself, but when Gradle starts dx it always uses -Xmx1024
.
So how can I make Gradle limit the memory used by dx?
In your build.gradle script, set the dexOptions.javaMaxHeapSize configuration to whatever value you need:
android {
//snip
//add this into your existing 'android' block
dexOptions {
javaMaxHeapSize "4g"
}
//snip
}
Source
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With