Simple tips on how to speed up your Android builds.
This talk is inspired by Stefan Oehme ( Gradle, Lead Developer) talk on “IMPROVING ANDROID BUILD PERFORMANCE” - Droidcon Berlin 2018
8. Currently the newest
version is: 4.8.1
Check gradle version
{project_home}/gradle/wrapper/gradle-wrapper.properties
9. - In 4.8.1 disable Google’s experimental “Configure on demand”
* What went wrong:
A problem occurred evaluating project ':repository'.
> Failed to apply plugin [id 'com.android.library']
> Configuration on demand is not supported by the current version of the Android Gradle plugin since you are using
Gradle version 4.6 or above. Suggestion: disable configuration on demand by setting
org.gradle.configureondemand=false in your gradle.properties file or use a Gradle version less than 4.6.
Check gradle version
- “instant run” is lost due to Android Studio & gradle incompatibility
21. Predex libraries
android {
dexOptions {
preDexLibraries true
}
}
Predexing builds dex file out of libraries so it can be used in
incremental builds (not building dex files each time for libraries). Using
this feature increases clean build time.
23. Solution:
- Use gradle > 4.7
- Use only Annotation Processor which
do support incremental builds
- Google’s data-binding AP does NOT
support it (work in progress)
https://github.com/gradle/gradle/issues/5277
Incremental Annotation Processors:
32. - download repository here + docs
- compile
- make an alias for ‘gradle-profiler’
Install gradle profiler:
> ./gradlew installDist
cp ./build/install/gradle-profiler/* ~/custom/gradle-profiler
alias gradle-profiler='~/custom/gradle-profiler/bin/gradle-profiler'