Google has released an update to the Android Gradle Plugin (AGP) that introduces a new approach to app optimization through what it calls optimized resource shrinking. The feature, available in AGP version 8.12.0, aims to reduce app size by integrating resource and code optimization into a single process.
Traditionally, resource shrinking has been handled separately from code optimization. The Android Asset Packaging Tool (AAPT2) generates rules to keep certain classes that appear to be tied to resources, which are then passed on to R8, Google’s app optimizer. While effective, this approach often results in unused code and resources being retained unnecessarily.
The updated pipeline changes that process by allowing R8 to evaluate both code and resource references simultaneously. Resources that are only linked to code identified as unused are now discarded, eliminating the need for the unconditional keep rules previously generated by AAPT2. This integration provides a more precise method for removing unused components.
Google reported significant app size reductions during internal testing, particularly for applications that share resources and code across multiple form factors. In some cases, app size decreased by more than 50 percent. Smaller apps also saw measurable gains, with examples such as Androidify demonstrating reductions when optimized resource shrinking was applied.
Beginning with AGP version 9.0.0, optimized resource shrinking will become the default behavior whenever resource shrinking is enabled in a project. Developers can find setup instructions and technical details in Google’s official blog post.
Comments
Loading…