Skip to content

Proguard Rules#316

Open
itsmechinmoy wants to merge 15 commits intoRyanYuuki:mainfrom
itsmechinmoy:proguard
Open

Proguard Rules#316
itsmechinmoy wants to merge 15 commits intoRyanYuuki:mainfrom
itsmechinmoy:proguard

Conversation

@itsmechinmoy
Copy link
Collaborator

No description provided.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.pro with keep/dontwarn rules for Flutter and several dependencies.
  • Enable minifyEnabled and shrinkResources for the release build 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.** { *; }
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-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.

Suggested change
-keep class com.google.gson.** { *; }

Copilot uses AI. Check for mistakes.
Comment on lines +70 to +73
-keep class okhttp3.** { *; }
-keep class retrofit2.** { *; }
-dontwarn okhttp3.**
-dontwarn okio.**
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Suggested change
-keep class okhttp3.** { *; }
-keep class retrofit2.** { *; }
-dontwarn okhttp3.**
-dontwarn okio.**
-dontwarn okhttp3.**

Copilot uses AI. Check for mistakes.
Comment on lines +9 to +12
-ignorewarnings

# ============================================================
# Flutter
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
-ignorewarnings
# ============================================================
# Flutter
# ============================================================
# Flutter
# Flutter

Copilot uses AI. Check for mistakes.
Comment on lines +6 to +7
-optimizationpasses 5
-dontpreverify
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-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.

Suggested change
-optimizationpasses 5
-dontpreverify

Copilot uses AI. Check for mistakes.
Comment on lines +40 to +43
-keep class ** implements kotlin.Metadata
-keep class ** extends kotlin.Metadata
-keepclassmembers class kotlin.Metadata {
public <methods>;
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-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.

Suggested change
-keep class ** implements kotlin.Metadata
-keep class ** extends kotlin.Metadata
-keepclassmembers class kotlin.Metadata {
public <methods>;
-keep class kotlin.Metadata { *; }
-keepclassmembers class ** {
@kotlin.Metadata *;

Copilot uses AI. Check for mistakes.
Comment on lines +24 to +28
# 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.** { *; }
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
# 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.**

Copilot uses AI. Check for mistakes.
@itsmechinmoy
Copy link
Collaborator Author

@RyanYuuki merge not major change should work properly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants