Android & Jetpack Compose (50 Qs)•Part 2: Compose Internals, Persistence, DI & Background Work (11 - 24)
What is ProGuard / R8 and how does it optimize Android APK/AAB size?
senior LevelDocker & Containers
In Simple Words: R8 is the default compiler and code shrinker for Android builds:
- Shrinking: Tree-shakes and strips unused classes, fields, and library methods.
- Optimization: Inlines functions, removes dead branches, and optimizes bytecode.
- Obfuscation: Renames classes and methods to short unreadable names (
a.b.c()), reducing DEX file size and preventing reverse engineering.
- Requires maintaining Proguard Rules (
-keep class ...) for classes accessed via reflection (e.g. JSON data models).