10 tips to speed up Android Gradle build


A few months ago, in the year’s Google I/O, there is a wonderful tutorial to guild us how to speed up Android Gradle build. Grade always has a notorious reputation about the slow build for large modules dependency project, those upgrade will solve those problems.

I copy a few of them here for the future reference. Although I still wait for the latest Android Studio 3.0 and grade plugin release which those tips dependence on.

# Tip 1: Use the lastes Android Gradle plugin
buildscript {
repositories {
jcenter()
maven { url 'http://maven.google.com' }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-alpha1'
}
}
# Tip 2: Avoid legacy multidex
# legacy multidex = Multidex + minSdkVersion < 21
# Android Studio 2.3+ will automatically avoid this when running from IDE when possible.
productFlavors {
development {
minSdkVersion 21
}
}
# Tip 3: Disable multi-APK
android {
if (project.hasProperty('devBuild')) {
splits.abi.enable = false
splits.density.enable = false
}
}
# or from cmd: ./gradlew project:assembleDevelopmentDebug -PdevBuild
# Tip 4: Include minimal resources
productFlavors {
development {
minSdkVersion 21
resConfigs("en", "xxhdpi")
}
}
# Tip 5: Disable png crunching
android {
if (project.hasProperty('devBuild')) {
aaptOptions.cruncherEnabled = false
}
}
# Tip 6: Use Instance Run
# Tip 7: Avoid inadvertent changes
# Tip 8: Don't use dynamic versions
# Tip 9: Watch the memory
# Tip 10: Enable Gradle Caching
# New from gradle 3.5, differ from 2.3 build cache
# Set this in gradle.properties
# org.gradle.caching = true

Comments

Popular posts from this blog

How Bluetooth LE works? -- Link Layer

Bluedroid stack in android

Network programming in elisp