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
180
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
190
Jon Markoff - Voice in the enterprise
droidcon_berlin_2018
0
60
Michael Jess - Enabling enterprise mobility with SAP
droidcon_berlin_2018
0
110
Ronen Sabag - Lean async code with Kotlin’s coroutines
droidcon_berlin_2018
0
63
Zan Markan - The state of Kotlin
droidcon_berlin_2018
0
70
Miquel Beltran - No More □ (tofu) Mastering Emoji on Android
droidcon_berlin_2018
0
120
Laurent Gasser & Jeremy Rochot - Sharing a success story - A low cost, Customer driven and co-developed Android EMM
droidcon_berlin_2018
0
270
Hoi Lam - Adding ML Kit to Android Things And some TensorFlow things
droidcon_berlin_2018
1
210
Nicola Corti - The curious case of Android button
droidcon_berlin_2018
0
64
Other Decks in Programming
See All in Programming
ボトムアップの生成AI活用を推進する社内AIエージェント開発
aku11i
0
1.6k
Kotlinで実装するCPU/GPU 「協調的」パフォーマンス管理
matuyuhi
0
360
外接に惑わされない自システムの処理時間SLIをOpenTelemetryで実現した話
kotaro7750
0
240
AIを駆使して新しい技術を効率的に理解する方法
nogu66
0
570
AIの弱点、やっぱりプログラミングは人間が(も)勉強しよう / YAPC AI and Programming
kishida
6
3.4k
Making Angular Apps Smarter with Generative AI: Local and Offline-capable
christianliebel
PRO
0
110
知られているようで知られていない JavaScriptの仕様 4選
syumai
0
350
ノーコードからの脱出 -地獄のデスロード- / Escape from Base44
keisuke69
0
670
Stay Hacker 〜九州で生まれ、Perlに出会い、コミュニティで育つ〜
pyama86
0
190
AIエージェントでのJava開発がはかどるMCPをAIを使って開発してみた / java mcp for jjug
kishida
3
240
詳細の決定を遅らせつつ実装を早くする
shimabox
1
980
業務でAIを使いたい話
hnw
0
260
Featured
See All Featured
How to Ace a Technical Interview
jacobian
280
24k
Build your cross-platform service in a week with App Engine
jlugia
234
18k
GraphQLとの向き合い方2022年版
quramy
49
14k
Rebuilding a faster, lazier Slack
samanthasiow
84
9.3k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
249
1.3M
YesSQL, Process and Tooling at Scale
rocio
174
15k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
132
19k
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.3k
Stop Working from a Prison Cell
hatefulcrawdad
272
21k
The Straight Up "How To Draw Better" Workshop
denniskardys
239
140k
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
31
2.7k
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