Making Gradle builds faster

Optimize your gradle

1. — dry-run

which will make Gradle actually skip the execution of all tasks.

./gradlew :android:assembleDebug --dry-run

2. — profile

./gradlew :android:assembleDebug --dry-run --profile

enable profiling on the Gradle build. Just slap the — profile flag on the Gradle command and you’ll get a nice report saying where the time went. The profile is locate in

build/reports/profile/

The profile shows that the majority of the time goes into configuring the projects:

3. Use configure on demand

There is a straightforward way to reduce that number. We need to make Gradle configure everything on demand rather than eagerly. Luckily for us, it’s just the matter of adding another command line flag: — configure-on-demand.

./gradlew :android:assembleDebug --dry-run --profile --configure-on-demand

4. Make the configuration faster

add the following code to ~/.gradle/gradle.properties

# Use configure on demand
org.gradle.configureondemand=true
# Use Gradle daemon
org.gradle.daemon=true
# enable parallel builds
org.gradle.parallel=true

Thanks Mr. Oleg Shelajev:

Reference: https://zeroturnaround.com/rebellabs/making-gradle-builds-faster/

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.