From d8ee1d807326b048d7dd2bab76746a062f14309b Mon Sep 17 00:00:00 2001 From: Armand <4831c0@proton.me> Date: Tue, 8 Sep 2026 22:44:26 +0200 Subject: [PATCH] fix(android): resolve ProGuard configuration path in release builds --- firka/android/app/build.gradle.kts | 22 +++++++- firka/android/app/proguard-rules.pro | 76 +++++++++++++++++++++++++++- firka/android/gradle.properties | 3 ++ 3 files changed, 99 insertions(+), 2 deletions(-) diff --git a/firka/android/app/build.gradle.kts b/firka/android/app/build.gradle.kts index b464c729..05da638d 100644 --- a/firka/android/app/build.gradle.kts +++ b/firka/android/app/build.gradle.kts @@ -59,7 +59,7 @@ android { if (config != null) { signingConfig = config } - proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") + proguardFiles("proguard-rules.pro") } } } @@ -94,6 +94,26 @@ tasks.register("ensureEnv") { tasks.matching { it.name.startsWith("compileFlutterBuild") }.configureEach { dependsOn("ensureEnv") } + +// Ensure default ProGuard files exist at the projectDir location expected by AGP/R8 when build directory is relocated +val defaultProguardDir = file("${project.projectDir}/build/intermediates/default_proguard_files/global") +defaultProguardDir.mkdirs() +val defaultProguardOptimize = File(defaultProguardDir, "proguard-android-optimize.txt-9.2.0") +if (!defaultProguardOptimize.exists()) { + defaultProguardOptimize.writeText("-allowaccessmodification\n") +} +tasks.register("ensureProguardFiles") { + doLast { + defaultProguardDir.mkdirs() + if (!defaultProguardOptimize.exists()) { + defaultProguardOptimize.writeText("-allowaccessmodification\n") + } + } +} +tasks.matching { it.name.startsWith("compile") || it.name.contains("minify", ignoreCase = true) || it.name.contains("r8", ignoreCase = true) }.configureEach { + dependsOn("ensureProguardFiles") +} + flutter { source = "../.." } \ No newline at end of file diff --git a/firka/android/app/proguard-rules.pro b/firka/android/app/proguard-rules.pro index e780808a..607651cb 100644 --- a/firka/android/app/proguard-rules.pro +++ b/firka/android/app/proguard-rules.pro @@ -1 +1,75 @@ --keep class app.firka.naplo.glance.** { *; } \ No newline at end of file +# Firka custom keep rules +-keep class app.firka.naplo.glance.** { *; } + +# Android optimize rules (-allowaccessmodification) +-allowaccessmodification + +# Android common keep rules +-keepattributes AnnotationDefault, + EnclosingMethod, + InnerClasses, + RuntimeVisibleAnnotations, + RuntimeVisibleParameterAnnotations, + RuntimeVisibleTypeAnnotations, + Signature + +-keep public class com.google.vending.licensing.ILicensingService +-keep public class com.android.vending.licensing.ILicensingService +-keep public class com.google.android.vending.licensing.ILicensingService +-dontnote com.android.vending.licensing.ILicensingService +-dontnote com.google.vending.licensing.ILicensingService +-dontnote com.google.android.vending.licensing.ILicensingService + +# Native methods +-keepclasseswithmembernames,includedescriptorclasses class * { + native ; +} + +# Keep setters in Views so that animations can still work. +-keepclassmembers public class * extends android.view.View { + void set*(***); + *** get*(); +} + +# We want to keep methods in Activity that could be used in the XML attribute onClick. +-keepclassmembers class * extends android.app.Activity { + public void *(android.view.View); +} + +# For enumeration classes +-keepclassmembers enum * { + public static **[] values(); + public static ** valueOf(java.lang.String); +} + +-keepclassmembers class * implements android.os.Parcelable { + public static final ** CREATOR; +} + +# Preserve annotated Javascript interface methods. +-keepclassmembers class * { + @android.webkit.JavascriptInterface ; +} + +# The support libraries contains references to newer platform versions. +-dontnote android.support.** +-dontnote androidx.** +-dontwarn android.support.** +-dontwarn androidx.** + +# Understand the @Keep support annotation. +-keep class android.support.annotation.Keep +-keep @android.support.annotation.Keep class * {*;} +-keepclasseswithmembers class * { + @android.support.annotation.Keep ; +} +-keepclasseswithmembers class * { + @android.support.annotation.Keep ; +} +-keepclasseswithmembers class * { + @android.support.annotation.Keep (...); +} + +-dontnote org.apache.http.** +-dontnote android.net.http.** +-dontnote java.lang.invoke.** \ No newline at end of file diff --git a/firka/android/gradle.properties b/firka/android/gradle.properties index 5126356f..e8b0a6c0 100644 --- a/firka/android/gradle.properties +++ b/firka/android/gradle.properties @@ -15,3 +15,6 @@ kotlin.incremental.useClasspathSnapshot=true android.builtInKotlin=false android.newDsl=false + +# Prevent AGP 9.0+ build failures due to relocated build directory ProGuard path mismatches +android.proguard.failOnMissingFiles=false