Verify R8 and ProGuard Release Optimization
Diagnose minification and shrinking problems in Android release builds, write narrow keep rules, and verify the exact optimized artifact and its mapping.
Record the Android Gradle Plugin, application and dependency versions, variant, and expected release configuration. Use an isolated test build of the optimized release artifact. Match the shrinker, resource optimization, and signing conditions relevant to the bug without exposing production signing material. A passing debug build is useful for comparison, while a failing optimized release is the evidence needed for a shrinker-specific diagnosis. ## Key Points - [Android enable R8 optimization](https://developer.android.com/topic/performance/app-optimization/enable-app-optimization/) - [Android troubleshoot optimization](https://developer.android.com/topic/performance/app-optimization/troubleshoot-the-optimization) - [Android keep-rule documentation](https://developer.android.com/topic/performance/app-optimization/add-keep-rules)
skilldb get android-kotlin-skills/r8-proguard-release-optimizationFull skill: 33 linesVerify R8 and ProGuard Release Optimization
Reproduce the release failure
Record the Android Gradle Plugin, application and dependency versions, variant, and expected release configuration. Use an isolated test build of the optimized release artifact. Match the shrinker, resource optimization, and signing conditions relevant to the bug without exposing production signing material. A passing debug build is useful for comparison, while a failing optimized release is the evidence needed for a shrinker-specific diagnosis.
Describe the user action that fails. Reflection, serialization, JNI callbacks, and runtime resource lookup are common entry points to examine. Use a small synthetic fixture for the suspected path. Keep the same inputs in minified and unminified comparisons so that any difference is attributable to the build configuration. Record crash or error evidence before modifying the configuration.
Identify the missing requirement
Use the matching mapping file to retrace an obfuscated stack. Associate the mapping with the exact release artifact and build identifier. Store both securely with the normal release metadata. If the mapping cannot be tied to that artifact, report the missing evidence and reproduce on a known build rather than reading a mismatched source line.
Inspect the relevant release rules and library-supplied consumer rules. Determine what the runtime path actually requires. It may need a class kept, a name preserved, an annotated member available, or metadata retained. Write a narrow keep rule that expresses that requirement. Prefer library-provided or generated rules when the dependency documents them. If the class is owned by your library and downstream apps need the rule, add it through the library's documented consumer configuration and verify it in a consuming app. Use tool reports to determine why existing rules already retain a class before adding another.
Avoid broad wildcard rules that keep a whole application package to silence one crash. A temporary isolation change can help diagnose whether shrinking or obfuscation is involved. Remove it after identifying the specific dynamic boundary. Changes to unrelated names or aggressive configuration options should have their own test and review.
Verify the result under the release configuration
Rebuild the same variant and rerun the failing interaction and a neighboring path. Check at least one app launch, the affected serialization or callback, and any service or UI entry point that references the same classes. Compare resulting package size and keep-rule reach against the prior optimized artifact. For a diagnostics fixture, generate an obfuscated stack from the rebuilt artifact and verify retracing with its matching mapping.
Keep the before-and-after test results, narrow rule, rationale, output artifact ID, mapping reference, and unresolved device or distribution checks together. If only a source or Gradle review was possible, record the actual missing optimized runtime evidence and leave release signoff open.
References
Install this skill directly: skilldb add android-kotlin-skills
Related Skills
Retrofit
Retrofit HTTP client for type-safe REST API communication in Android with Kotlin coroutines
Room Database
Room persistence library for local SQLite database access with compile-time query verification in Android
Testing
Android testing with JUnit5 for unit tests and Espresso/Compose testing for UI verification
Wear OS Compose, Tiles and Complications
Design and validate a glanceable Wear OS feature across Compose app screens, Tiles and watch face complications. Use when choosing surfaces, navigation, data updates, or representative watch tests.
Architecture
MVVM architecture pattern with ViewModel, LiveData, and StateFlow for scalable Android apps
Android Gradle Variants, Signing and Logcat
Diagnose Android build type and product flavor mismatches, inspect the merged app variant and signing identity, and collect Logcat evidence from the exact running process.