Slide 1

Slide 1 text

Compiling Android Apps

Slide 2

Slide 2 text

ART History ● Android apps don’t run on the Java Virtual Machine (JVM) ● The first Android vm was called Dalvik. It had some problems. ● Nowadays, they run on a virtual machine called the Android Runtime (ART) ○ Remember when Oracle sued Google of Patent/Copyright infringement? ● ART makes certain affordances and optimizations for Android platform features and is actually quite different from the desktop JVM. ● For example: ○ JVM is a stack based architecture. ART is register based. ○ ART can elect to ahead-of-time compile an app at device install time.

Slide 3

Slide 3 text

Optimized Builds The old way Kotlin source Java bytecode Optimized Java bytecode Optimized Dex bytecode kotlinc ProGuard (or DexGuard for $$$) DX (or recently D8)

Slide 4

Slide 4 text

Aside: Naming things is hard.

Slide 5

Slide 5 text

Optimized Builds The new way Kotlin source Java bytecode Optimized Dex bytecode kotlinc R8

Slide 6

Slide 6 text

Why does this matter? ● Whole program optimization with nice Kotlin support ● Resource shrinking ● Tree shaking / 64k reference limit ● Bytecode obfuscation

Slide 7

Slide 7 text

Non-Optimized Build: Left // Optimized Build: Right

Slide 8

Slide 8 text

Goodbye classes2.dex 💥

Slide 9

Slide 9 text

35% reduction of .apk size