Shipping unoptimized Android binaries wastes bandwidth and slows app launch times. Google’s R8 compiler integrates code shrinking, dead-code stripping, and name obfuscation into a single unified build pass.
The Three Operations of R8
- Shrinking: Traverses the call graph to detect and remove unused classes, methods, and library dependencies.
- Optimization: Inlines small methods, removes unused arguments, and rewrites control flow structures for faster execution.
- Obfuscation: Renames packages, classes, and fields to single-letter tokens (e.g.
a.b.c) to thwart reverse-engineering.