So many AndroidDev joking about Android Studio heater

Android Gradle Builds won’t be faster, here is why

Cedric Ferry

--

One of the biggest pain point for Android Developers is the build time. This is a real concern, so why despite the successive versions of Gradle and Android Gradle Plugin, building an Android app takes so long?

Android Studio, your winter heater

It has been a running joke for a few years now, Android Studio, or more precisely Gradle, is using the CPU intensively, resulting in most computers to overheat and requiring their fan system to go at full speed (especially MacBook Pro Intel edition).

This is a reality, a thing that Android Developers experience everyday, with computers becoming incredibly hot, and this gets even worse during summer days. Obviously, such situation is very far from the ideal work environment. To add to that, build time seems to become slower and slower, day after day, version after version.

Gradle, a Java tool

When looking a little closer, we can notice that when a Gradle task is started, Java is started too.

java process when ./gradlew assembleDebug is running

We can see that the CPU is used at more than 700% by Java. Thanks to multi-core / multi-thread, Gradle and Java can use all the resources available in order to speed up the build (at least they try).

Gradle build are also using an important amount of memory, up to 1500MB for this build (which is a single activity of 1 screen with Jetpack Compose, with a couple of buttons).

Java is known for using a lot of RAM and a fair bit of CPU too. This is because it is running a Virtual Machine, which is heavy to launch, but gets better once it is warm. A second build with ./gradlew clean assembleDebug will run much faster (even with clean), essentially because almost everything is already loaded into memory. This is where Java can perform well, also thank tp Gradle Deamon.

Improvements in the last few years

Despite Gradle build feeling slow, the teams worked a lot on improving the performance, and they explored a few areas:

Parallel compilation

--

--