Android Gradle Build Speed Optimizations Explained
Slow build times can be frustrating for developers, leading to decreased productivity. There are several strategies and techniques that can be used to optimize the build speed of Android applications. In this article, we will explore some of the most effective Android build speed optimizations and explain how they reduce the build time.
Before starting, I will explain my setup for the benchmarks and how I benchmarked different parameters.
I used gradle-profiler
for benchmarking. This is a gradle profiler developed by gradle. Basically, you provide some different parameters and it runs each of them and creates a report that compares each build’s total execution time. I used a macbook with 16 GB Ram and 2,9 GHz Quad-Core Intel Core i7. The Android project that profiler ran is a multi-module project with 7 modules. Java version is 11.
How to Use gradle-profiler?
Firstly, install profiler:
brew install gradle-profiler
Then we should create multiple scenarios with different parameters and define these scenarios in a file. gradle-profiler
will execute these scenarios and will create a report.
Command to run the profiler:
gradle-profiler --benchmark --project-dir…