From 90f1f48810d5da81f1c4922307f2e4522461bc82 Mon Sep 17 00:00:00 2001 From: inventory69 Date: Tue, 10 Feb 2026 17:01:01 +0100 Subject: [PATCH] perf(v1.8.0): optimize ProGuard/R8 rules for smaller APK size MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Replace broad '-keep class dev.dettmer.simplenotes.** { *; }' with targeted rules - Keep only Gson data models and enum values that require reflection - Allow R8 to shrink/obfuscate remaining app code - Update rules for: Note, ChecklistItem, DeletionTracker, BackupData models - Keep enum values() and valueOf() for state serialization - Remove unnecessary keep rules for non-reflection classes - Add structured comments for maintainability APK size reduced from 5.0 MB → 4.8 MB (200 KB saved). R8 now has better optimization opportunities while maintaining functionality. All unit tests pass, lint reports clean (0 errors, 0 warnings). Build: BUILD SUCCESSFUL - 4.8M app-fdroid-release.apk --- android/app/proguard-rules.pro | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/android/app/proguard-rules.pro b/android/app/proguard-rules.pro index 87335da..4e87efa 100644 --- a/android/app/proguard-rules.pro +++ b/android/app/proguard-rules.pro @@ -59,8 +59,25 @@ -keep class * implements com.google.gson.JsonSerializer -keep class * implements com.google.gson.JsonDeserializer -# Keep your app's data classes --keep class dev.dettmer.simplenotes.** { *; } +# ═══════════════════════════════════════════════════════════════════════ +# App-specific rules: Only keep what Gson/reflection needs +# ═══════════════════════════════════════════════════════════════════════ + +# Gson data models (serialized/deserialized via reflection) +-keep class dev.dettmer.simplenotes.models.Note { *; } +-keep class dev.dettmer.simplenotes.models.Note$NoteRaw { *; } +-keep class dev.dettmer.simplenotes.models.ChecklistItem { *; } +-keep class dev.dettmer.simplenotes.models.DeletionRecord { *; } +-keep class dev.dettmer.simplenotes.models.DeletionTracker { *; } +-keep class dev.dettmer.simplenotes.backup.BackupData { *; } +-keep class dev.dettmer.simplenotes.backup.BackupResult { *; } + +# Keep enum values (used in serialization and widget state) +-keepclassmembers enum dev.dettmer.simplenotes.** { + ; + public static **[] values(); + public static ** valueOf(java.lang.String); +} # v1.7.1: Suppress TextInclusionStrategy warnings on older Android versions # This class only exists on API 35+ but Compose handles the fallback gracefully