Reputation: 20934
One of the build optimizations suggested by Google is to enable dexInProcess
for your build (see here):
android {
dexOptions {
dexInProcess = true
}
}
Can somebody explain what it actually does? Tried to search through official docs, but there is not much about this feature (probably because android plugin 2.0.0 is still in its alpha stage, so not fully released to public)
Upvotes: 3
Views: 1756
Reputation: 20934
From the latest AS release I think I got much better understanding of this flag. Previously DEX step was happening in a separate external process. The idea of this flag is that DEX step runs in the same process as your build which makes build process much faster.
The only important thing you should be aware of, is that DEX step is really memory consuming (remember dexOptions.javaMaxHeapSize "4g"
option we used to set before?), so since now DEX step runs in the same process as your build, you need to make sure you allocated enough memory to your JVM. Otherwise build will be slowed down dramatically or even throw OutOfMemoryException.
I would suggest giving build process 4 gigs by updating jvmargs
in your gradle.properties
as follows:
org.gradle.jvmargs=-Xmx4g -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
Upvotes: 6