There is an undocumented dexOptions flag.
dexOptions {
javaMaxHeapSize "2g"
}
I found the flag from a google groups post. https://groups.google.com/forum/#!topic/adt-dev/P_TLBTyFWVY
题
I have an Android project which is currently running out of heap space during the dex step:
:app:dexXXXXX Exception in thread "pool-1-thread-4" java.lang.OutOfMemoryError: Java heap space
I would like to bump up the jvm min/max settings in gradle like 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 only see these options:
android {
dexOptions {
incremental false
preDexLibraries = false
jumboMode = false
}
}
Is there a way to do it? There is a gradle.properties file but that just seems to have jvmargs for gradle itself.
解决方案
There is an undocumented dexOptions flag.
dexOptions {
javaMaxHeapSize "2g"
}
I found the flag from a google groups post. https://groups.google.com/forum/#!topic/adt-dev/P_TLBTyFWVY