This is unofficial documentation for R8, Google’s code shrinker for Android™. Google intends R8 to be a drop-in replacement for ProGuard, and has provided documentation in the Android Studio User Guide to help you get started with it. However, they rely on the ProGuard Manual for detailed documentation, even though there are substantial differences between R8 and ProGuard. This documentation is meant to supplement the Android Studio User Guide and the ProGuard Manual to fill that gap.
This site is open source on GitHub™ and we encourage you to contribute by opening issues or submitting pull requests.
Assumptions
This documentation assumes that you are using the standard Gradle™ build process of an Android application or library with version 3.4 or later of the Android Gradle Plugin. It is not suitable if you are using R8 directly in a custom build process.
Note: Known issues reflected in this document were last tested on R8 v1.6.67 using Android Gradle Plugin v3.6.1.
Obfuscation, Shrinking, Renaming, and Minification - What’s the Difference?
The Android Studio documentation and the R8 ruleset itself use the term “obfuscation” in a way that isn’t very precise. As we make an Android Obfuscator, we think it’s important to understand the distinction between Obfuscation, Renaming, Shrinking, and Minification.
- Obfuscation generally refers to a broad set of techniques that make code more difficult to understand and reverse engineer, but in the context of R8 rules and documentation it specifically refers to Renaming of packages, classes, methods, and fields that R8 performs. R8 employs renaming primarily to reduce the size of the application or library on which it is operating, not to protect it from reverse engineering. We avoid using the term “obfuscation” in this documentation in favor of “renaming”.
- Code Shrinking or Tree Shaking refers to the removal of unused classes and members from your application or library, primarily to reduce its size.
-
Minification, as in
minifyEnabled
, is sometimes used to describe the combination of Shrinking and Renaming for the purpose of reducing the size of an application or library.
In addition to Renaming and Code Shrinking, R8 also performs Optimization, which rewrites code to improve its performance and further reduce its size. The Android Gradle Plugin also performs Resource Shrinking, which reduces the size of resources in a similar manner to the way that Code Shrinking reduces the size of applications or libraries. This is not a feature of R8 itself, but they are related processes; the Android Gradle Plugin requires that you enable a code shrinker to shrink resources.
Who We Are
We are PreEmptive Solutions. We believe a comprehensive obfuscation solution must do more than just minification. We make PreEmptive Protection™ DashO™, which provides powerful obfuscation and shielding for Android applications and libraries.
DashO 10.x allows you to leverage DashO’s powerful protection features, including Control Flow Obfuscation, String Encryption and Resource Encryption, without sacrificing R8’s features and build performance. It also includes active Checks, such as Root Checks, Debugging Checks, Emulator Checks, and Tamper Checks.
Download a free trial of DashO 10 which includes our world-class support.