So most of the time you can receive significant improvements just by adopting the latest version of the tooling.

At the time of this refactor, our project was on version 3.

2.

1 of the Gradle plugin for Android Studio (which is a few versions older than the latest release).

You can visit this link to get the version for the latest release of the Gradle Plugin.

At the time of writing this post, the latest version happens to be version 3.

4.

0.

But it comes with a gotcha that we need to keep in mind for later:https://developer.

android.

com/studio/releases/gradle-pluginWhen using Gradle 5.

0 and above we will need to explicitly increase the heap size to ensure our build speed doesn’t worsen.

We will come back to this in just a minute.

Open the top level build.

gradle file which you will find in the root of your project and add the following line in the dependencies section:classpath 'com.

android.

tools.

build:gradle:3.

4.

0'You will also need to update the distribution URL in the gradle wrapper properties file located at gradle/wrapper/gradle-wrapper.

properties.

Update the URL to the following.

(This link will be available on the Android Gradle plugin release page.

)distributionUrl=https://services.

gradle.

org/distributions/gradle-5.

1.

1-all.

zipIf you are using Kotlin in your project, you will run into an error if your Kotlin Gradle plugin’s version is less than 1.

3.

0.

If that’s the case, use the IDE’s prompt to update your Kotlin Gradle plugin to the latest version (which at the time of writing this post happens to be version 1.

3.

31).

Alright, let’s run the build again from the terminal to see if we achieved any improvements.

Step #2: Update your configurationsSo we were able to shed around 2.

5 minutes from the build time but it’s still not good enough.

Upon investigating the build logs in the terminal, I came across one line which is of interest to us:Incremental compilation basically prevents wasteful compilation of the entire set of source files and instead compiles only the files that have changed.

Looking at the logs, it’s clear that we’re not taking advantage of this feature.

It suggests us to use android.

enableSeparateAnnotationProcessing=true but since we’re using Kotlin in our projects, we should not be using the ‘annotationProcessor’ configuration anyways.