Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Compiling Android Apps

Compiling Android Apps

A brief introduction to the compilation pipeline for Android apps.

Avatar for Justin Brooks

Justin Brooks

April 11, 2023
Tweet

More Decks by Justin Brooks

Other Decks in Technology

Transcript

  1. 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.
  2. Optimized Builds The old way Kotlin source Java bytecode Optimized

    Java bytecode Optimized Dex bytecode kotlinc ProGuard (or DexGuard for $$$) DX (or recently D8)
  3. Why does this matter? • Whole program optimization with nice

    Kotlin support • Resource shrinking • Tree shaking / 64k reference limit • Bytecode obfuscation