Upgrade to Pro — share decks privately, control downloads, hide ads and more …

5 years on air - Sergiy Grechukha

GDG Cherkasy
December 16, 2017

5 years on air - Sergiy Grechukha

Android gradle plugin tricks around application build time

GDG Cherkasy

December 16, 2017
Tweet

More Decks by GDG Cherkasy

Other Decks in Programming

Transcript

  1. What is the prefered way? Teams must cause a minimal

    effect at each other’s workflow
  2. What is the prefered way? Separate builds for each stream

    Stream1 Stream2 Stream3 Stream 200600 Stream 100500
  3. Income Main screen + second screen for each stream FeatureA

    FeatureB FeatureC FeatureD MAIN SCREEN
  4. KeepSafe/dexcount-plugin > Task :app:countFullDebugDexMethods Total methods in app-full-debug.apk: 52157 (79.59%

    used) Total fields in app-full-debug.apk: 23616 (36.04% used) Total classes in app-full-debug.apk: 12664 (19.32% used) Methods remaining in app-full-debug.apk: 13378 Fields remaining in app-full-debug.apk: 41919 Classes remaining in app-full-debug.apk: 52871
  5. Gradle profiler Run using: ToolingApi Cleanup Tasks: [] Tasks: [clean,

    assembleFullDebug] Gradle args: [] Build changes: none Warm-ups: 6 Builds: 10 * Running scenario using Gradle 3.5 (scenario 1/1) * Stopping daemons * Running warm-up build 1 with tasks [clean, assembleFullDebug] Execution time 60924ms * Running warm-up build 2 with tasks [clean, assembleFullDebug] Execution time 30091ms
  6. Gradle profiler build,3.5 tasks,clean assembleFullDebug build 1,19746 build 2,25880 build

    3,22192 build 4,22437 build 5,27784 build 6,28752 mean, 24465.16667 median, 24158.5
  7. Step 1 Update gradle plugin! (gradle-4.1-milestone-1 which was used with

    android gradle plugin (AGP) 3.0.0-alpha6) build,4.1-milestone-1 tasks,clean assembleFullDebug build 1,25061 build 2,24898 build 3,23100 build 4,23677 build 5,24808 build 6,21733 mean, 23879.5 median, 24242.5 gradle.properties: org.gradle.configureondemand=true org.gradle.jvmargs=-Xmx1536m
  8. Step 2 (hard one) - modules • show top level

    build.gradle • show build.gradle (Module app) • show build.gradle (app-shell) Notes: • Common ext.vars • implementation/api dsl • downstreaming flavor policy
  9. Step 2 (hard one) - modules build,4.1-milestone-1 tasks,clean assembleFullDebug build

    1,23142 build 2,19861 build 3,20159 build 4,19912 build 5,18319 build 6,19007 mean, 20066.66667 median, 19886.5 4 seconds == 17% are squeezed out
  10. Simple math: if build time == 5 min 1 dev

    builds app 4 times per hour There are 5 devs in one stream There are 4 streams 8 hour per day I’ve squeezed 1 min 1 min 4 min 20 min 80 min 640 min
  11. Step 3 - caching org.gradle.caching=true build,4.1-milestone-1 tasks,clean assembleFullDebug build 1,10153

    build 2,10176 build 3,9951 build 4,9735 build 5,9774 build 6,9022 build 7,9106 build 8,9401 build 9,9309 build 10,9330 mean,9533.7777777777 median,9401.0
  12. Few more words about build time for dev build: Do

    not use dynamic values (for app version for instance)
  13. Conclusions • All of this stuff can easily be ignored

    on powerful PCs. • Modularizing the app is not so easy • Be careful with unreleased new features (aapt2) • Once you designed your multimodule architecture do not forget about tests • Switching to modules is a question of time and sooner or later you’ll switch
  14. Links • Git module app • Git singleModule app •

    More on this topic Useful links: • Gradle summit 2017 • Migrate to android gradle plugin 3.0