Created
January 17, 2018 04:40
-
-
Save Shah-Sahab/8b464996b693d001a2c926fe52e18e41 to your computer and use it in GitHub Desktop.
Speeding up the Gradle Build Process Google I/O 2017
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
**NOTES FROM VIDEO** | |
Main Difference it talks about is the difference between compile dependencies vs implementation and api. | |
New Dependency Config in 3.0: | |
1. compile is not deprecated. | |
2. Replace with Api or implementation. | |
Note: Difference b/w compile & Implementation & Api is discussed after the discussion of the Tips I have added below. | |
Note: doLast is bad (36:00) | |
Tips From 2017 I/O for Increasing build speed are as following, | |
1. Switching from old 2.2 plugin to 3.0 reduces the amount of time it takes to make a build. (4:25) | |
2. Avoid Legacy Multidex. (6:20) | |
Legacy multidex = Multidex + minSdkVersion <21 (Legacy multidex slows down build significantly). | |
Android studio 2.3+ will automatically avoid this when running from IDE when possible. | |
3. Disable MultiAPK Generation (7:40) | |
4. Minimize resources (9:40) | |
under you product flavor, e.g, | |
debug { // or if you call it a development) | |
// Define your language and the density that you'll need for your build. | |
// It will only allow the following language and density to be added to this //build while reducing the speed for your particular build flavor. | |
resConfigs ("en", "xxhdpi") | |
} | |
5. Disabling png Crunching (10:50) | |
Android build tools perform PNG size optimizations by default. (Not that important for a debug/development builds) | |
Or Consider using WebP (11:50) | |
OS version Reqs: | |
Opaque - API level 15+ | |
With transparency - API level 18+ | |
6. Use Instant Run (13:06) | |
7. Avoid inadvertent changes (15:33) | |
Things like introducing dateTime as a versionCode. This is forcing your manifest to change at every build ending up increasing time of creating builds. | |
Another example of Crashlytics (17:22) Generates a build Id on every build. | |
It can be turned off on select versions of your product flavors by using the following flag, | |
ext.alwaysUpdateBuildId = false (but be careful, see the video for more info). | |
8. Do not use Dynamic Versions (18:02) | |
e.g. | |
compile "com.android.support:appcompat-v7:+" - BAD | |
Above compile dependency Increases Dependency Resolution Time. Avoid this as you may also not know what new came in or got removed. | |
9. Amount of Memory you are giving to Gradle (18:52) | |
gradle-properties: (cant add . in fb for gradle properties) | |
// By default gradle getrs 1.5 g of memory. | |
org.gradle.jvmargs=-Xmx1536m // Experiment with this value | |
build.gradle: | |
dexOptions { | |
javaMaxHeapSize = "4g" //Be careful! | |
10. Enable the New Gradle Cache (19:50) | |
Set this in gradle-properties | |
org.gradle.caching=true | |
https://www.youtube.com/watch?v=7ll-rkLCtyk&feature=youtu.be&t=22m20s |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment