Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Boris Farber & Nikita Kozlov - The_Build_Side_o...
Search
droidcon Berlin
July 17, 2018
Programming
0
170
Boris Farber & Nikita Kozlov - The_Build_Side_of_Android_App
droidcon Berlin
July 17, 2018
Tweet
Share
More Decks by droidcon Berlin
See All by droidcon Berlin
Jon Markoff - Best practice for apps
droidcon_berlin_2018
0
170
Jon Markoff - Voice in the enterprise
droidcon_berlin_2018
0
53
Michael Jess - Enabling enterprise mobility with SAP
droidcon_berlin_2018
0
91
Ronen Sabag - Lean async code with Kotlin’s coroutines
droidcon_berlin_2018
0
44
Zan Markan - The state of Kotlin
droidcon_berlin_2018
0
63
Miquel Beltran - No More □ (tofu) Mastering Emoji on Android
droidcon_berlin_2018
0
110
Laurent Gasser & Jeremy Rochot - Sharing a success story - A low cost, Customer driven and co-developed Android EMM
droidcon_berlin_2018
0
210
Hoi Lam - Adding ML Kit to Android Things And some TensorFlow things
droidcon_berlin_2018
1
180
Nicola Corti - The curious case of Android button
droidcon_berlin_2018
0
61
Other Decks in Programming
See All in Programming
SpringBoot3.4の構造化ログ #kanjava
irof
2
970
Ruby on cygwin 2025-02
fd0
0
140
時計仕掛けのCompose
mkeeda
1
280
ファインディの テックブログ爆誕までの軌跡
starfish719
2
1.1k
密集、ドキュメントのコロケーション with AWS Lambda
satoshi256kbyte
0
170
ペアーズでの、Langfuseを中心とした評価ドリブンなリリースサイクルのご紹介
fukubaka0825
2
300
sappoRo.R #12 初心者セッション
kosugitti
0
230
ARA Ansible for the teams
kksat
0
150
Domain-Driven Transformation
hschwentner
2
1.9k
いりゃあせ、PHPカンファレンス名古屋2025 / Welcome to PHP Conference Nagoya 2025
ttskch
1
270
データの整合性を保つ非同期処理アーキテクチャパターン / Async Architecture Patterns
mokuo
41
15k
Djangoアプリケーション 運用のリアル 〜問題発生から可視化、最適化への道〜 #pyconshizu
kashewnuts
1
230
Featured
See All Featured
Six Lessons from altMBA
skipperchong
27
3.6k
4 Signs Your Business is Dying
shpigford
182
22k
Music & Morning Musume
bryan
46
6.3k
Bash Introduction
62gerente
610
210k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
175
51k
Building Better People: How to give real-time feedback that sticks.
wjessup
366
19k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5.2k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
99
18k
GitHub's CSS Performance
jonrohan
1030
460k
Build The Right Thing And Hit Your Dates
maggiecrowley
34
2.5k
The Cult of Friendly URLs
andyhume
78
6.2k
Raft: Consensus for Rubyists
vanstee
137
6.8k
Transcript
The Build Side of an Android App Nikita Kozlov Zalando
SE @Nikita_E_Kozlov Boris Farber Google @borisfarber
Background • Build improvement is the most requested feature from
developers • Worked with a few companies to speed up their builds • Share best practices and patterns
Problem • You add new features, libraries and frameworks. •
You refactor your code to smaller classes, add tests • Somehow, the build times add up
We don’t think about our build as a design component
Build challenge • Analysing build takes time • Difficult to
estimate and prioritize • Build improvement might be ambiguous
Focus on following • Build Tools versions • Hardware •
Modularization
Our process Create a test project Implement suggestion Test &
Measure Implement within a real project Android Studio Poet Gradle Profiler*
Incremental build change a Java/Kotlin file assembleDebug
Build Tools versions
Versions we tested • Gradle: 4.3.1 to 4.8 • Android
Gradle Plugin: from 3.0.1 to 3.1.2 • Kotlin: from 1.1.60 to 1.2.50
What about Build Tools versions? 2x speed up just from
the build tools
Another easy win From the build scan: • Compilation -
35% • Dexing - 55%
Dexing is a limiting step .CLASS .CLASS .CLASS .DEX .DEX
.DEX Will be faster if min SDK is 21 .CLASS
Incremental build with min SDK 21 Set min SDK to
21 during development to increase your build speed
Better Hardware
Hardware MacBook Pro 2015 • 13-inch • 2.7 GHz Intel
Core i5 • 16 GB 1867 MHz DDR3 MacBook Pro 2017 • 15-inch • 2,8 GHz Intel Core i7 • 16 GB 2133 MHz LPDDR3 vs
Hardware • Better hardware reduces build time significantly • Sometimes
even more than modularization
Background processes matters • Background processes reduces build time •
Antivirus made build speed 3 times slower
Modularization
Modularization - theory Module 2 Module 3 Module 1 App
Module App Module Key principles: 1. Parallelization 2. Caching 3. Compile avoidance
Compile Avoidance App Feature Incremental build after a change of
method’s body in Feature: 8s Incremental build after a adding a public method to Feature: 10s
Extracting rarely-changed code reduces build time App Incremental build with
a change in App: 55s Incremental build with a change in App: 39s App Utils
Work against tests whenever you can App Incremental build of
App with a change in App: 55s Incremental build of Utils module: 26s App Utils
Change in the library module vs application module App Utils
Incremental build of App module: 39s Incremental build of Utils module: 26s
Intermodule dependencies increase build time Incremental build with change in
Feature 3: 1m 5s Incremental build with change in Feature 3: 1m 11s Feature 1 Feature 3 Feature 2 App Feature 2 Feature 3 Feature 1 App
Start simple if you don’t have time App Tracking Utils
Core UI Networking App Feature Feature Feature Common code
Use a topology that works for you App App Monolith
Incremental build with change in App: 81s Incremental build with change in Main: 92s
Use a topology that works for you App Feature App
Monolith Feature Incremental build with change in Feature: 10s Incremental build with change in Feature: 7s
Modularization rules of thumb • Extract utils and other rarely-changed
code • Keep in mind the intermodule dependencies • Developing library modules in TDD way helps • Measure on a test project first
Our process Create a test project Implement suggestion Test &
Measure Implement within a real project Android Studio Poet Gradle Profiler
• Tool to generate large self contained Android projects •
https://github.com/android/android-studio-poet • Accepts JSON config file for the parameters Android Studio Poet
Features Java Butterknife Kotlin External Libraries Gradle Plugins Flavours Build
Types Intermodule dependencies Build Tools versioning String resources Images Layouts Activities Data Binding External repositories Dependency visualization Packages Classes Methods Fields
Two input formats Compact Full
Demo
Learn more • Extend Android Studio Poet - https://github.com/android/android-studio-poet/blob/master/exten d/Extending.md
• For this talk we made about 50 configs and more then 500 builds • Our configs, we used for this presentation https://github.com/android/android-studio-poet/tree/master/config s
Thanks ! And to Sergio Murguia, Google and Stefan Oehme,
Gradle
Questions ? Nikita Kozlov Zalando SE @Nikita_E_Kozlov Boris Farber Google
@borisfarber