← All toolsproguard-rules.pro⬇ Download Turn on R8 in app/build.gradle
Tools · ProGuard / R8
ProGuard / R8 rules
Tick the libraries your app uses and get a ready proguard-rules.pro, with a note on every rule. Fixes the classic works-in-debug, crashes-in-release bugs.
Quick start:
# proguard-rules.pro
# Generated by Hang Daro's ProGuard / R8 Rules Generator.
# Libraries not listed here ship their own rules.
# ---- JSON model classes (data classes for API responses) ----
-keep class com.example.app.data.model.** { *; }
# ---- Readable crash reports (line numbers) ----
-keepattributes SourceFile,LineNumberTable
-renamesourcefileattribute SourceFile
android {
buildTypes {
release {
isMinifyEnabled = true
isShrinkResources = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}
}Testing tips
- Always test a release build on a real phone before uploading: install it with flutter build apk --release or ./gradlew assembleRelease.
- If something breaks only in release, check the R8 output in build/outputs/mapping/release/: usage.txt lists removed code, mapping.txt maps renamed names.
- Keep mapping.txt for every release (Play Console stores it for AABs) so crash reports can be decoded.