Fix release build: add androidx.window R8 keep rules, wire proguard-rules.pro

This Flutter SDK's Gradle plugin enables R8 release minification by default (FlutterPluginUtils.shouldShrinkResources() returns true), so release builds run minifyReleaseWithR8. R8 then fails on the optional androidx.window.extensions/sidecar classes - compile-time-only stubs referenced by the transitive androidx.window dependency and provided by the OEM at runtime.

- proguard-rules.pro: -dontwarn androidx.window.extensions/sidecar (per R8's own missing_rules.txt) - build.gradle.kts: make isMinifyEnabled/isShrinkResources explicit and add proguardFiles so proguard-rules.pro is actually applied (it was never referenced before, leaving its rules dormant)
This commit is contained in:
Imran Remtulla
2026-06-29 02:45:32 +01:00
parent 34ddb7c07f
commit 5ad3cb1f2d
2 changed files with 18 additions and 1 deletions

View File

@@ -77,6 +77,12 @@ android {
buildTypes {
getByName("release") {
isMinifyEnabled = true
isShrinkResources = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro",
)
val releaseSigningConfig = signingConfigs.getByName("release")
signingConfig = if (keystorePropertiesExists && releaseSigningConfig.storeFile != null) {
releaseSigningConfig

View File

@@ -29,4 +29,15 @@
-keep,allowobfuscation,allowshrinking class com.google.gson.reflect.TypeToken
-keep,allowobfuscation,allowshrinking class * extends com.google.gson.reflect.TypeToken
##---------------End: proguard configuration for Gson ----------
##---------------End: proguard configuration for Gson ----------
##---------------Begin: androidx.window ----------
# androidx.window (pulled in transitively, e.g. via the Flutter embedding / WebView)
# references optional OEM-provided window-management extension and sidecar classes
# reflectively. They are not present at compile time, so R8 flags them as missing.
# Suppressing is safe: the classes are supplied by the device at runtime (or absent,
# in which case the library gracefully falls back). See missing_rules.txt generated by
# R8 at build/app/outputs/mapping/normalRelease/missing_rules.txt.
-dontwarn androidx.window.extensions.**
-dontwarn androidx.window.sidecar.**
##---------------End: androidx.window ----------