官方優(yōu)化教程: https://developer.android.com/studio/build/optimize-your-build.html
重要部分
1. 防止編譯不需要資源
android {
...
productFlavors {
dev {
...
// The following configuration limits the "dev" flavor to using
// English stringresources and xxhdpi screen-density resources.
resConfigs "en", "xxhdpi"
}
...
}
}
上面的resConfigs
的語(yǔ)言選項(xiàng)放吩,如果想設(shè)置簡(jiǎn)體中文,需要把en
改為zh-rCN
,語(yǔ)言標(biāo)識(shí)規(guī)范來(lái)源于這兒
2. 防止Crashlytics每次更新 build id導(dǎo)致更新 resource
android {
...
buildTypes {
debug {
ext.alwaysUpdateBuildId = false
}
}
3. 禁用png crunch
android {
...
aaptOptions {
cruncherEnabled false
}
}
3. 使用build cache
這篇 http://www.reibang.com/p/6a32cba7d40d
最后伪嫁,測(cè)量full build時(shí)間的gradle命令如下:
gradlew --profile --recompile-scripts --offline --rerun-tasks assembleFlavorDebug