AS Poet
Optimise your Android Studio builds
Boris Farber
Google
@borisfarber
Slide 2
Slide 2 text
About me
● Android/Java/Kotlin
● Partner Engineer at Google
● Focusing on Android app optimizations (ClassyShark, AS Poet)
Slide 3
Slide 3 text
Disclaimer
If you have a Android small app,
forget these slides
Slide 4
Slide 4 text
Optimize your Android build
Slide 5
Slide 5 text
Some metrics we have seen
● From 5% to 50% build improvement time
● Disclaimer ⇒ Heavily depends on
○ Project
○ Team skills
○ Etc…
● Take these number with a huge grain of salt
Slide 6
Slide 6 text
Why
● You work relentlessly on your awesome Android app. You add new features,
libraries and frameworks.
● Some more code here, some more resources there, it all ends up impacting
the build time.
Slide 7
Slide 7 text
Why
● But it doesn’t have to be that way!
● As you refactor your classes and methods, why not to treat your Android
project as a refactor-able unit
Slide 8
Slide 8 text
Many variables that affect our build speed
● Annotations
● Resources
● Java Modules
● Android modules
● Number of classes
● Number of methods
● Dependencies
● Topology
● …
Slide 9
Slide 9 text
What
● It requires a lot of testing, experiments, manual work, and patience.
Slide 10
Slide 10 text
AS Poet
● What if we will generate many synthesized Android projects with a
configurable number of metrics that mimics your project
● Then we analyze the build times and understand where are the places to
refactor
Slide 11
Slide 11 text
AS Poet
● A desktop based utility for Android developers
● Generates synthesized Android projects with a configurable number of
metrics
Slide 12
Slide 12 text
How
● Let's take a simple JSON file (less than 20 lines), that mimics the Android
projects with gradle plugin syntax
● Has number of other parameters such as class/method count ...
● AS Poet will read the script and generate a buildable Android Studio project
Features
● GUI and CLI
● Share resources between Android modules (layouts ...)
● Call Java/Koltin code between different modules
● Build flavours
● Topologies
● Full format for fain gained control over modules
● ...
Slide 23
Slide 23 text
Optimize Kotlin on desktop
Slide 24
Slide 24 text
Swing
● Zero Kotlin documentation
● All documentation (really good) is 20 years old
● Ended up doing skeleton development in Java and convert to Kotlin
Slide 25
Slide 25 text
AS Poet
● A desktop based utility for Android developers
● IO bound app (generates folders with 100K with interconnected
dependencies)
Slide 26
Slide 26 text
Optimizations
● Measure, measure and measure
● It is better to solve the right problem the wrong way than the wrong problem
the right way
● Our architecture - coroutunes for module creation with fork/join for individual
classes write
Slide 27
Slide 27 text
Coroutines
● Used at module & project generation generation
● 5x overall improvement