r8-shrinker-tamer

Diagnose release-build R8 crashes and APK bloat caused by missing ProGuard keep rules.

Updated Jan 2, 2024
One-click install
npx skills add https://github.com/Mithrandir21/game-deals-app --skill r8-shrinker-tamer-mithrandir21
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: r8-shrinker-tamer
Source: https://github.com/Mithrandir21/game-deals-app/tree/main/.claude/skills/r8-shrinker-tamer
Command: npx skills add https://github.com/Mithrandir21/game-deals-app --skill r8-shrinker-tamer-mithrandir21

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Release builds that crash while debug builds work fine are almost always caused by R8 stripping or renaming code that reflection-based libraries (Moshi, Retrofit, Hilt, Compose, kotlinx.serialization) depend on. This Skill provides a systematic process to reproduce, diagnose, and fix those failures, plus investigate APK size bloat. ## Core Features & Use Cases - Crash Diagnosis: Maps common release-only crash signatures (NoSuchMethodException, serialization failures, Hilt class stripping) to their root causes and deobfuscates stack traces with mapping.txt. - Keep Rule Authoring: Provides narrow, correct ProGuard rule patterns for Moshi data classes, Retrofit interfaces, enums, and Parcelables instead of broad rules that defeat shrinking. - APK Size Investigation: Walks through APK Analyzer, resource shrinking, native library splits, and dependency audits to reduce release artifact size. - Use Case: Your app crashes in production with "Cannot serialize" errors but works in debug. Use this Skill to reproduce locally with minifyEnabled, identify the stripped Moshi-generated adapter, and add a targeted keep rule. ## Quick Start Ask the assistant to diagnose why my Android release build crashes with R8 minification enabled while the debug build works fine.

Frequently Asked Questions about r8-shrinker-tamer

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
Why does my Android app crash in release but work in debug?▼

Release builds run R8, which renames and strips code that reflection-based libraries like Moshi, Retrofit, and Hilt need at runtime. The fix is adding targeted keep rules to proguard-rules.pro, not disabling minification.

How do I fix R8 missing rules for Moshi or Retrofit?▼

First check the merged configuration at app/build/outputs/mapping/release/configuration.txt to confirm the library's consumer ProGuard rules are applied. If missing, add narrow rules such as keeping @JsonClass-annotated classes and your Retrofit service interfaces.

How do I deobfuscate a release build stack trace?▼

Use the mapping.txt file generated at app/build/outputs/mapping/release/ to retrace obfuscated stack traces, either through Android Studio or the retrace tool. Keep the mapping file paired with every released APK and upload it to your crash reporter.

Does kotlinx.serialization need ProGuard rules?▼

Usually not, because the compiler plugin generates serializers at compile time. You may only need rules for polymorphic serialization that relies on runtime reflection.

How do I reduce APK size with R8?▼

Enable both minifyEnabled and shrinkResources, then analyze the APK in Android Studio to find large resources, unused native ABIs, and heavy dependencies. Use App Bundles so each device downloads only the resources it needs.

Why is disabling obfuscation a bad fix for release crashes?▼

Setting dontobfuscate or minifyEnabled false gives up the size and performance benefits of R8 and leaves your code exposed. The correct approach is keeping obfuscation on and shipping mapping.txt to your crash reporting tool.