Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Boris Farber & Nikita Kozlov - The_Build_Side_o...
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
droidcon Berlin
July 17, 2018
Programming
230
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Boris Farber & Nikita Kozlov - The_Build_Side_of_Android_App
droidcon Berlin
July 17, 2018
Transcript
37 slides
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
More Decks by droidcon Berlin
See All by droidcon Berlin
Jon Markoff - Best practice for apps
droidcon_berlin_2018
0
230
Jon Markoff - Voice in the enterprise
droidcon_berlin_2018
0
90
Michael Jess - Enabling enterprise mobility with SAP
droidcon_berlin_2018
0
140
Ronen Sabag - Lean async code with Kotlin’s coroutines
droidcon_berlin_2018
0
94
Zan Markan - The state of Kotlin
droidcon_berlin_2018
0
92
Miquel Beltran - No More □ (tofu) Mastering Emoji on Android
droidcon_berlin_2018
0
150
Laurent Gasser & Jeremy Rochot - Sharing a success story - A low cost, Customer driven and co-developed Android EMM
droidcon_berlin_2018
0
350
Hoi Lam - Adding ML Kit to Android Things And some TensorFlow things
droidcon_berlin_2018
1
250
Nicola Corti - The curious case of Android button
droidcon_berlin_2018
0
78
Other Decks in Programming
See All in Programming
AI時代のFlutter品質設計 — アプリ品質を守るQuality Layers
omatty198
0
370
あなたの await、OS まで届いてる? strace で覗く JavaScript の非同期
hasutosasaki
1
2.3k
선언형 햅틱 라이브러리 진동을 소개합니다
l2hyunwoo
1
310
LLM 101
dalinaum
0
480
Herb in Rails 8.2: Your ERB views, now HTML-aware @ Kaigi on Rails 2026, Tokyo, Japan
marcoroth
2
430
Apple Intelligenceとオンデバイス時代の到来
yahir0
0
240
Web3Dライブラリを作ってVue Custom Rendererの仕組みを理解しよう / lets learn vue custom renderer by making 3d library
drumath2237
1
130
Spec-driven Development with AI
simas
PRO
0
2.3k
graphql-ruby を Spinel で速くしようとした話
mtsmfm
0
140
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
260
まずはコードより業務と向き合う:テーブル解体のためにPdMを呼んだ話
sakawe_ee
0
210
Modernizing iOS Apps
seyfoyun
0
150
Featured
See All Featured
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.4k
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
350
The Spectacular Lies of Maps
axbom
PRO
1
1.1k
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
1
850
Bioeconomy Workshop: Dr. Julius Ecuru, Opportunities for a Bioeconomy in West Africa
akademiya2063
PRO
1
460
Everyday Curiosity
cassininazir
0
400
Test your architecture with Archunit
thirion
2
2.5k
The Illustrated Children's Guide to Kubernetes
chrisshort
51
53k
Stop Working from a Prison Cell
hatefulcrawdad
274
21k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
18k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
23k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
3.1k