Optimise R8/ProGuard rules to meet the Play 25% DEX optimisation requirement

XMLWordPrintable

    • Type: Task
    • Resolution: Done
    • Priority: Low
    • 2.14
    • Affects Version/s: None
    • None
    • FLW Sprint 54, FLW Sprint 55
    • FLW Mobile App
    • UAT

      R8 is enabled for release, but app/proguard-rules.pro has broad keep rules that switch it off for most of the code:

      • -keep class org.piramalswasthya.sakhi.** { *; }

        keeps the whole app.

      • kotlin.*, kotlinx.coroutines., com.google.firebase., com.google.android.gms., okhttp3., retrofit2., moshi.* and org.bouncycastle.** are fully kept.
      • -keepclassmembers class ** { public static <fields>; }

        applies to every library.

      The debug build has 53 MB of DEX, so the release build is very likely over the 10 MB limit, with optimisation coverage well below 25%.

      Scope:

      • Remove the broad keep rules. Keep only what is accessed by reflection:
      • Moshi and Gson DTOs (model.*, network.*);
      • JNI native methods used by KeyUtils;
      • classes marked with @Keep.
      • Add -keepattributes SourceFile,LineNumberTable and make sure the Crashlytics mapping file is uploaded, so crash reports stay readable.
      • Remove the -optimizations and -verbose lines, which R8 doesn't use.
      • Optional: enable R8 full mode once the build is stable.
      • Add a CI step that builds one release variant when the ProGuard rules or Gradle files change.

      Acceptance Criteria:

      • [ ] Release DEX size is significantly lower than the Task 1 baseline.
      • [ ] Play Console DEX optimisation is at least 25%.
      • [ ] Crashlytics stack traces are de-obfuscated correctly.
      • [ ] Task 3 regression passes.

        1. dex4.png
          dex4.png
          441 kB
        2. dex3.png
          dex3.png
          72 kB

              Assignee:
              Nikhil Ananda Fegade
              Reporter:
              Nikhil Ananda Fegade
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: