How to configure jvm args for dex memory in gradle?

I have an Android project that currently ends out of the heap during the dex step:

:app:dexXXXXX Exception in thread "pool-1-thread-4" java.lang.OutOfMemoryError: Java heap space 

I would like to increase the jvm min / max settings in gradle, as we used to do with the Maven plugin:

  <groupId>com.jayway.maven.plugins.android.generation2</groupId> <artifactId>android-maven-plugin</artifactId> <version>3.6.0</version> <extensions>true</extensions> <configuration> <sdk> <platform>${android.platform}</platform> </sdk> <undeployBeforeDeploy>true</undeployBeforeDeploy> <dex> <jvmArguments> <jvmArgument>-Xms1024m</jvmArgument> <jvmArgument>-Xmx2048m</jvmArgument> </jvmArguments> </dex> 

But in the docs for the android plugin in gradle, I see only these options:

  android { dexOptions { incremental false preDexLibraries = false jumboMode = false } } 

Is there any way to do this? There is a gradle.properties file, but it seems to have only jvmargs for gradle.

+7
android jvm gradle
source share
1 answer

There is an undocumented flag dexOptions.

dexOptions { javaMaxHeapSize "2g" }

I found a flag from google groups post. https://groups.google.com/forum/#!topic/adt-dev/P_TLBTyFWVY

+17
source share

All Articles