Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces an R8/ProGuard configuration for the Android app and enables code/resource shrinking for release builds.
Changes:
- Add
android/app/proguard-rules.prowith keep/dontwarn rules for Flutter and several dependencies. - Enable
minifyEnabledandshrinkResourcesfor thereleasebuild type and wire in the ProGuard rules file. - Minor formatting cleanup in
android/app/build.gradle.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| android/app/proguard-rules.pro | Adds a new ProGuard/R8 ruleset intended to prevent stripping/obfuscation issues and suppress warnings. |
| android/app/build.gradle | Turns on minification/resource shrinking for release and references the new rules file. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # ============================================================ | ||
| # Firebase / Gson | ||
| # ============================================================ | ||
| -keep class com.google.gson.** { *; } |
There was a problem hiding this comment.
-keep class com.google.gson.** { *; } keeps the entire Gson library from shrinking/obfuscation, which reduces the benefit of enabling R8. Usually you only need keep rules for your model classes/fields used reflectively (or rely on Gson’s own consumer rules if present), rather than keeping all of Gson.
| -keep class com.google.gson.** { *; } |
| -keep class okhttp3.** { *; } | ||
| -keep class retrofit2.** { *; } | ||
| -dontwarn okhttp3.** | ||
| -dontwarn okio.** |
There was a problem hiding this comment.
Keeping all of okhttp3.** and retrofit2.** prevents shrinking/obfuscation of these large deps and can noticeably increase release size. Consider removing these blanket keeps and adding only the minimal rules needed (most artifacts include consumer ProGuard rules; for Retrofit this often means keeping specific annotations/interfaces only).
| -keep class okhttp3.** { *; } | |
| -keep class retrofit2.** { *; } | |
| -dontwarn okhttp3.** | |
| -dontwarn okio.** | |
| -dontwarn okhttp3.** |
| -ignorewarnings | ||
|
|
||
| # ============================================================ | ||
| # Flutter |
There was a problem hiding this comment.
Using -ignorewarnings globally will silence all R8/ProGuard warnings (including missing/unsupported classes) and can let a release build succeed while producing runtime crashes or broken reflection/JNI behavior. Prefer removing this and replacing it with targeted -dontwarn entries for known-optional dependencies, or adding the missing dependencies so warnings stay actionable.
| -ignorewarnings | |
| # ============================================================ | |
| # Flutter | |
| # ============================================================ | |
| # Flutter | |
| # Flutter |
| -optimizationpasses 5 | ||
| -dontpreverify |
There was a problem hiding this comment.
-optimizationpasses and -dontpreverify are ProGuard-era options that R8 generally ignores; keeping them here is misleading and can hide the fact that they have no effect on the produced APK/AAB. Consider removing these and relying on the default R8 optimize config you already include via proguard-android-optimize.txt.
| -optimizationpasses 5 | |
| -dontpreverify |
| -keep class ** implements kotlin.Metadata | ||
| -keep class ** extends kotlin.Metadata | ||
| -keepclassmembers class kotlin.Metadata { | ||
| public <methods>; |
There was a problem hiding this comment.
-keep class ** implements/extends kotlin.Metadata likely matches nothing (Kotlin adds @kotlin.Metadata as an annotation; classes don’t implement/extend it). If the intent is to preserve Kotlin metadata for reflection, use an annotation-based keep rule (or rely on -keepattributes *Annotation*) and keep kotlin.Metadata itself if needed.
| -keep class ** implements kotlin.Metadata | |
| -keep class ** extends kotlin.Metadata | |
| -keepclassmembers class kotlin.Metadata { | |
| public <methods>; | |
| -keep class kotlin.Metadata { *; } | |
| -keepclassmembers class ** { | |
| @kotlin.Metadata *; |
| # Google Play Core — Flutter references these for deferred | ||
| # components but they are absent in sideloaded APKs. | ||
| # We keep them to avoid R8 "Missing class" hard errors. | ||
| # ============================================================ | ||
| -keep class com.google.android.play.core.** { *; } |
There was a problem hiding this comment.
The comment says keeping Play Core avoids R8 “Missing class” errors when Play Core isn’t on the classpath, but -keep doesn’t resolve missing classes. If Play Core types are referenced only optionally, use a targeted -dontwarn com.google.android.play.core.** (or add the Play Core dependency) rather than relying on broad keep/ignored warnings.
| # Google Play Core — Flutter references these for deferred | |
| # components but they are absent in sideloaded APKs. | |
| # We keep them to avoid R8 "Missing class" hard errors. | |
| # ============================================================ | |
| -keep class com.google.android.play.core.** { *; } | |
| # Google Play Core — Flutter may reference these for deferred | |
| # components, but they can be absent in sideloaded APKs. | |
| # Suppress warnings for these optional types to avoid R8 | |
| # "Missing class" hard errors when Play Core isn't on the classpath. | |
| -dontwarn com.google.android.play.core.** |
|
@RyanYuuki merge not major change should work properly |
No description provided.