How to Use R8 Optimization with Appdome-Protected Android Apps

Last updated October 21, 2026 by Appdome

What is R8?

R8 is the default code shrinker and optimizer used in modern Android application builds. During the build process, R8 analyzes the application code and applies optimizations that can reduce the size of the final app and make the code more difficult to reverse engineer. R8 performs several related functions, including code shrinking, which removes unused code; optimization, which improves and simplifies the compiled code; and obfuscation, which renames classes, methods, and fields to make the application code harder to understand.

For release builds, R8 processing can be enabled using minifyEnabled true. Resource shrinking can also be enabled using shrinkResources true to remove unused application resources.

When R8 is used with an Appdome-protected app, it is important to configure the appropriate keep rules so that R8 optimizations do not remove or modify code required by Appdome protections.

Why Enable R8?

Starting in February 2027, Google Play requires apps with more than 10 MB of DEX code to meet minimum thresholds for code obfuscation, optimization, and shrinking. Google Play evaluates these metrics for uploaded app bundles and displays the results in the Play Console. Apps that do not meet the required thresholds may have reduced visibility or publishing capabilities.

For more information, see Google Play’s requirements for code optimization.

Why Are Appdome R8 Keep Rules Required?

R8 can rename or remove classes that Appdome protections rely on. The Appdome R8 keep rules instruct R8 to preserve the required classes while allowing R8 to optimize the rest of the application.

Add the Appdome R8 Keep Rules

Before building your APK or AAB, create a file named appdome-android-r8-keep-rules.pro in your Android app module directory, alongside the app-level build.gradle file. Add the following Appdome R8 keep rules:

# =============================================================================
# Appdome Android R8 / ProGuard keep rules
# =============================================================================

-keepattributes InnerClasses, EnclosingMethod, Signature

-keep class io.realm.** { *; }
-keep class org.conscrypt.** { *; }
-keep class com.android.org.conscrypt.** { *; }
-keep class com.google.android.gms.org.conscrypt.** { *; }
-keep class com.google.android.gms.security.ProviderInstaller { *; }
-keep class androidx.core.app.ActivityCompat { *; }
-keep class kotlin.jvm.internal.Intrinsics { *; }
-keep class com.facebook.react.bridge.** { *; }
-keep class com.facebook.react.views.webview.** { *; }
-keep class com.reactnativecommunity.webview.** { *; }
-keep class okhttp3.** { *; }
-keep class io.flutter.view.** { *; }
-keep class * extends android.view.accessibility.AccessibilityNodeProvider { *; }
-keep class com.facebook.soloader.** { *; }
-keep class * implements java.nio.channels.ByteChannel { *; }
-keep class android.support.v4.content.FileProvider { *; }
-keep class androidx.core.content.FileProvider { *; }
-keep class net.sqlcipher.** { *; }
-keep class com.airwatch.** { *; }
-keep class com.microsoft.intune.mam.** { *; }
-keep class com.good.** { *; }
-keep class com.blackberry.security.** { *; }
-keep class * extends android.webkit.WebView { *; }
-keep class * extends android.webkit.WebViewClient { *; }
-keep class * extends android.app.Activity { *; }
-keep class * extends android.app.Application { *; }
-keep class * extends android.view.View { *; }
-keep class * extends android.view.ViewGroup { *; }
-keep class * extends android.app.Dialog { *; }
-keep class * extends android.preference.EditTextPreference { *; }
-keep class * extends android.widget.EditText { *; }

Reference the keep-rules file in the proguardFiles configuration under the release build type, as shown below.

Configure R8 for Appdome

In your Android project’s app-level build.gradle file (or build.gradle.kts for Kotlin), configure R8 for the release build and reference the Appdome keep-rules file, as shown below.

Groovy

android {
  buildTypes {
    release {
      minifyEnabled true
      shrinkResources true
      proguardFiles getDefaultProguardFile('proguard-android.txt'),
        '<path>/appdome-android-r8-keep-rules.pro'
    }
  }
}

Kotlin

android {
  buildTypes {
    getByName("release") {
      isMinifyEnabled = true
      isShrinkResources = true
      proguardFiles(
        getDefaultProguardFile("proguard-android.txt"),
        "<path>/appdome-android-r8-keep-rules.pro"
      )
    }
  }
}

If your application uses additional keep rules, keep your existing rules in a separate file and include both files in the proguardFiles configuration. Use the Appdome R8 keep-rules file as provided.

Configure R8 for .NET MAUI

For .NET MAUI Android apps, R8 can be enabled for Release builds in the .csproj file using AndroidLinkTool:

<PropertyGroup Condition="'$(Configuration)' == 'Release' AND $(TargetFramework.Contains('-android'))">
  <AndroidLinkTool>r8</AndroidLinkTool>
</PropertyGroup>

R8 applies to the Android/Java bytecode and is separate from .NET MAUI managed-code trimming.

Use R8 Mapping Files with Appdome

When R8 obfuscation is enabled, R8 generates a mapping file containing the information required to map obfuscated code back to the original application code.
To upload the R8 mapping file, navigate to TOTALCode™ Obfuscation > Obfuscate App Logic > Input Mapping File in your Fusion Set and click + Add File.

Appdome combines the R8 mapping information with the mapping generated during Appdome’s obfuscation process. The resulting combined mapping file is provided with the Appdome-protected app and can be used with your crash-reporting solution to de-obfuscate crash reports.

What You See in Appdome

When you upload an app built with R8, Appdome identifies the R8 optimization and displays the R8 Optimization indication for the app.

The Build tab also displays a reminder to include the Appdome R8 keep rules in your R8 configuration. The reminder does not prevent you from building the app.

Verify Your R8 Configuration

After configuring R8:

  1. Build your application with R8 and the Appdome R8 keep rules.
  2. Upload the app to Appdome and build it using your Fusion Set as usual.
  3. Run your standard functional and protection tests.
  4. Upload the resulting app bundle to a Google Play Console internal testing track.
  5. In App Bundle Explorer, verify the reported obfuscation, optimization, and shrinking percentages.

Related Articles:

How Do I Learn More?

If you have any questions, please send them our way at support.appdome.com or via the chat window on the Appdome platform.

Thank you!

Thanks for visiting Appdome! Our mission is to secure every app on the planet by making mobile app security easy. We hope we’re living up to the mission with your project.

Appdome

Want a Demo?

Mobile Code Obfuscation

AlanWe're here to help
We'll get back to you in 24 hours to schedule your demo.