Extremely long build with Gradle (Android Studio)

I’m not quite sure why Android Studio is slower than the command line, but you can speed up your builds by turning on incremental dexing. In your module’s build file, add this option to your android block:

dexOptions {
    incremental true
}

In that dexOptions block you can also specify the heap size for the dex process, for example:

dexOptions {
    incremental true
    javaMaxHeapSize "4g"
}

These options are taken from a thread on the adt-dev mailing list (https://groups.google.com/forum/#!topic/adt-dev/r4p-sBLl7DQ) which has a little more context.

Leave a Comment