The DashO Gradle Plugin for Android works with R8 to protect an Android application or library. DashO applies Control Flow Obfuscation, String Encryption, Resource Encryption, and Checks, while R8 performs Renaming and Removal.
R8 is the default shrinker in Android Gradle Plugin 3.4.0 and later. However, you must still enable shrinking for every build type that DashO protects.
Enable shrinking for a build type
In the module-level build.gradle file, set minifyEnabled to true for the protected build type. For example, to enable R8 for a release build:
android {
buildTypes {
release {
minifyEnabled true
}
}
}Make sure the build type also matches the DashO plugin’s enabledBuildVariants setting. By default, the plugin protects variants whose names match release.
Configure R8 for older Android Gradle Plugin versions
If you maintain a project that uses Android Gradle Plugin 3.2.x or 3.3.x, R8 is not enabled by default. Add the following property to the root project’s gradle.properties file:
android.enableR8=trueVerify R8 and DashO protection
Run a build for the protected variant and verify that:
- The selected build type has shrinking enabled.
- The build output shows that DashO ran.
- The build completes without R8 or DashO errors.
If R8 removes or renames code required at runtime, add the applicable R8 keep rules for the application or library. Android libraries should preserve the public API intended for their consumers.