Enable Android Studio's "Dex In Process" for Faster App Builds

By: Android Developers

198   3   29754

Uploaded on 05/12/2016

Android Studio 2.1 enables Dex In Process, a feature that can dramatically improve all your build times. To take advantage of Dex In Process, you’ll need to modify your gradle.properties file and increase the amount of memory allocated to the Gradle Daemon VM by 1 Gb, to a minimum of 2 Gb, using the org.gradle.jvmargs property.

Learn more here about how to enable Dex In Process here: https://goo.gl/s4KpFw

Android Studio is available to download from: http://goo.gl/2qpr
Learn more about Android Studio with Android Tool Time with Reto Meier: https://goo.gl/mAitOr
Subscribe to the Android Developers channel at http://goo.gl/GEh1ds

#androidstudio #featured #tools

Comments (2):

By anonymous    2017-09-20

Update from June 25, 2017

At Google IO 2017 there was some updates about this topic. It's not recommended anymore to set the flag on the dexOptions, so if you have something like the next, you can delete it.

dexOptions {
   javaMaxHeapSize "2g"
}

Original answer:

Android Studio 2.1 enables Dex In Process which shares the VM with Gradle to improve build times. Due to this, it's necessary to increase the size of the Gradle daemon to incorporate those Dex processes.

At least it's necessary 2 gigs of memory, but you can try with three if you can afford it.

gradle.properties.

org.gradle.jvmargs=-Xmx3072m

By default the Java max heap size is one gig, but in case you have modified it on the build.gradle file...

build.gradle (App)

dexOptions {
   javaMaxHeapSize "2g"
}

...you have to resize the Gradle daemon size accordingly (has to be bigger to fit the heap).

Notes:

  • Please realize above numbers varies from machine to machine.

Original Thread

Recommended Books

    Popular Videos 293

    Submit Your Video

    If you have some great dev videos to share, please fill out this form.