Optimize your build speed in Android Studio

Updated 30 August 2019

Save

Why build time is so important?

As an android developer, we are spending a lot of time looking at your screen and waiting for Gradle build to finish. In the new Android studio, it has been a lot faster than the previous version but still, there is a lot of scopes to fasten it so Let’s Make it Fast by Doing some quick fixes in Android Studio.

These are the few tips which will help you to reduce your build time in Android Studio:

  1. Always use latest android Gradle Plugin -Android studio incrementally improves performance in newer Gradle version so it is recommended to use the latest one. By default, Android Studio now uses a new DEX compiler called D8. By default, Android Studio now uses D8(You can also disable it ). DEX compilation is the process of transforming .classbytecode into .dex bytecode for the Android Runtime (or Dalvik, for older versions of Android). Compared to the previous compiler, called DX, D8 compiles faster and outputs smaller DEX files, all while having the same or better app runtime performance. This newer plugin version will lead to up to 25% reduce the timing of build.
  2. Disable PNG Crunching- Android build tools perform PNG size optimization by default, It’s good for release build but for development, it increases build time. Either use WEBP instead of PNG or disable it in development flavor.

3. Instant RUN- instant run creates a lot of problems till Android Studio 3.0, now it is stable and works on devices sdkVersion ≥21. It also has applied changes that will reflect changes directly into the live process rather than restarting the app.

 

 

4. Enable Gradle caching-Caching Gradle will caches task outputs from any previous build from any location. set org.gradle.caching= true in Gradle.properties file to enable caching.


 

5. Multi-Module Project- Modularity also increase Gradle build time by building modules in parallel.

6. Don’t use dynamic dependency version- It will lead to check studio every time whether a new library version of this is available.

 

author
. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


Be the first to comment.

Start a Project


    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home