From 61e7533d6483952d7755ba802b90cb44edce8526 Mon Sep 17 00:00:00 2001 From: hailin Date: Tue, 10 Mar 2026 08:22:11 -0700 Subject: [PATCH] fix(android): add ProGuard rules to suppress HMS missing class errors R8 fails on missing optional HMS dependencies (HiAnalytics, libcore, BouncyCastle). Add dontwarn rules and wire proguard-rules.pro to release build type. Co-Authored-By: Claude Sonnet 4.6 --- it0_app/android/app/build.gradle.kts | 5 +++++ it0_app/android/app/proguard-rules.pro | 17 +++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 it0_app/android/app/proguard-rules.pro diff --git a/it0_app/android/app/build.gradle.kts b/it0_app/android/app/build.gradle.kts index 5b74ef3..0e66c68 100644 --- a/it0_app/android/app/build.gradle.kts +++ b/it0_app/android/app/build.gradle.kts @@ -79,6 +79,11 @@ android { // TODO: Add your own signing config for the release build. // Signing with the debug keys for now, so `flutter run --release` works. signingConfig = signingConfigs.getByName("debug") + isMinifyEnabled = true + proguardFiles( + getDefaultProguardFile("proguard-android-optimize.txt"), + "proguard-rules.pro" + ) } } diff --git a/it0_app/android/app/proguard-rules.pro b/it0_app/android/app/proguard-rules.pro new file mode 100644 index 0000000..3fb282c --- /dev/null +++ b/it0_app/android/app/proguard-rules.pro @@ -0,0 +1,17 @@ +# Flutter +-keep class io.flutter.app.** { *; } +-keep class io.flutter.plugin.** { *; } +-keep class io.flutter.util.** { *; } +-keep class io.flutter.view.** { *; } +-keep class io.flutter.** { *; } +-keep class io.flutter.plugins.** { *; } + +# Huawei HMS — optional internal classes not bundled in the app +-dontwarn com.huawei.android.os.** +-dontwarn com.huawei.hianalytics.** +-dontwarn com.huawei.hms.availableupdate.** +-dontwarn com.huawei.libcore.io.** +-dontwarn com.huawei.secure.android.** + +# BouncyCastle — referenced by HMS security but not shipped +-dontwarn org.bouncycastle.**