Improve App Performance With Optimized Resource Shrinking
Article Summary
Johan Bay from Google just dropped a game-changer for Android app size. Apps sharing resources across form factors are seeing 50%+ size reductions with one configuration change.
Google's Android team released optimized resource shrinking in AGP 8.12.0, fundamentally changing how R8 removes unused code and resources. Instead of treating code and resource optimization as separate steps, R8 now analyzes both simultaneously for far more aggressive pruning.
Key Takeaways
- Apps sharing resources across form factors see over 50% size reduction
- R8 now optimizes code and resources together, eliminating AAPT2 keep rules
- Smaller downloads, faster installs, reduced memory usage, and fewer ANRs
- Becomes default behavior in AGP 9.0.0 for all projects
- Enable with one flag: android.r8.optimizedResourceShrinking=true
Critical Insight
By unifying code and resource optimization into a single pass, R8's new approach removes unused resources that the old two-step process couldn't detect.