My (Cool) list of gradle properties.

Ansh Sachdeva
4 min readNov 2, 2021

--

“Gradlus Fastify” : say this spell 3 times every morning to run your gradle faster. And if that doesn’t work, then read on😉

Gradle to android developers is like magic to Harry Potter. We initially are unaware about it, then have a tough time with it, and after some years of training, (rough) experiences, and fiddling around, it becomes our main weapon of choice.

Recently I have been trying to understand the various working and usages of various files associated with gradle and although every file in an android project is a new world of possibilities, one particular file is very powerful yet so easy to ignore: thegradle.properties file

About

Backend developers of the Spring and ktor world would know that .properties files are like system configuration files which are accessible by the code and can be used to store custom properties as well as modify compiler and libraries behavior.

Well, guess what? That holds true for Android Project too! You can configure how the gradle will be caching or making builds, how the kapt annotation processor will behave, or how much memory should be given to the compilation process.

However, this makes it an important place to be considered while reviewing your codebase. You might be wondering why you are not getting the logs, and it may turn out that logging is disabled from this file.

So here are some of the few properties that i use in almost all my projects :

1.

org.gradle.daemon=true
org.gradle.configureondemand=true
org.gradle.jvmargs=-Xmx3g -XX:MaxPermSize=2048m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -XX:+UseParallelGC

These properties specifies the JVM arguments used for the daemon process. These settings are particularly useful for tweaking memory settings.

2.

org.gradle.warning.mode=all

This helps in showing all the warnings from the system gradle itself. Very helpful, if you like to stay at the cutting edge of your libraries’ versions.

3.

org.gradle.parallel=true

This improves build speeds by A LOT in multi-modular projects. it informs the compiler to build multiple app modules in parallel . more info here :

4.

org.gradle.caching=true

This improves build speeds when running app multiple times, like after taking a pull or adding some new library. it caches all the unchanged modules. more info :

5.

android.useAndroidX=true
android.enableJetifier=true

This is useful when you are using third-party libraries which might not be up to the date and using android support libraries. These settings inform the compiler to automatically convert them to androidx.

6.

kotlin.code.style=official

This is used to set the official code style for kotlin . more info here

7.

kapt.verbose=true # Enable Kapt Logcat to show warnings

8.

kapt.incremental.apt=true
kapt.use.worker.api=true

This enables incremental processing for annotations via kapt .The second command informs the compiler to use multiple threads and compile the annotations in parallel . These again give some MAJOR performance improvements and I have found my build times to reduce by at least 20% . more info here :

9.

android.databinding.incremental=true
android.lifecycleProcessor.incremental=true

These enable incremental annotation processing for individual modules(which are known to have the incremental processing disabled) .

Closing notes.

These are some of the properties that I discovered while suffering from large build times and surfing the internet for my various queries. I am sure there can be even more of these properties which would be improving our build process even more . So readers, If you know of any other properties/hacks / gradle tricks that you use in the parties, share them in the comments below.

Also feel free to connect with me if you like to talk about tech, webseries, food or cats. This is Ansh Sachdeva signing off!

--

--