From 6c4acee13a755e505ce51f07eb92846120f635bb Mon Sep 17 00:00:00 2001 From: MTRNord Date: Wed, 23 Feb 2022 17:49:22 +0100 Subject: [PATCH] Update proguard rules to a more modern setup Took 8 seconds --- android/app/build.gradle | 3 ++- android/app/proguard-rules.pro | 34 +++++++++++++++++++++++++++++++++- android/gradle.properties | 1 + 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index 4e018b38..3fe911a0 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -69,8 +69,9 @@ android { release { signingConfig signingConfigs.release minifyEnabled true + shrinkResources true - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } } diff --git a/android/app/proguard-rules.pro b/android/app/proguard-rules.pro index d0f7f6ed..40570865 100644 --- a/android/app/proguard-rules.pro +++ b/android/app/proguard-rules.pro @@ -6,4 +6,36 @@ -keep class io.flutter.view.** { *; } -keep class io.flutter.** { *; } -keep class io.flutter.plugins.** { *; } --dontwarn io.flutter.embedding.** \ No newline at end of file +-dontwarn io.flutter.embedding.** + +##---------------Begin: proguard configuration for Gson (Needed for flutter_local_notifications) ---------- +# Gson uses generic type information stored in a class file when working with fields. Proguard +# removes such information by default, so configure it to keep all of it. +-keepattributes Signature + +# For using GSON @Expose annotation +-keepattributes *Annotation* + +# Gson specific classes +-dontwarn sun.misc.** + +# Application classes that will be serialized/deserialized over Gson +-keep class com.google.gson.examples.android.model.** { ; } + +# Prevent proguard from stripping interface information from TypeAdapter, TypeAdapterFactory, +# JsonSerializer, JsonDeserializer instances (so they can be used in @JsonAdapter) +-keep class * extends com.google.gson.TypeAdapter +-keep class * implements com.google.gson.TypeAdapterFactory +-keep class * implements com.google.gson.JsonSerializer +-keep class * implements com.google.gson.JsonDeserializer + +# Prevent R8 from leaving Data object members always null +-keepclassmembers,allowobfuscation class * { + @com.google.gson.annotations.SerializedName ; +} + +# Retain generic signatures of TypeToken and its subclasses with R8 version 3.0 and higher. +-keep,allowobfuscation,allowshrinking class com.google.gson.reflect.TypeToken +-keep,allowobfuscation,allowshrinking class * extends com.google.gson.reflect.TypeToken + +##---------------End: proguard configuration for Gson (Needed for flutter_local_notifications) ---------- \ No newline at end of file diff --git a/android/gradle.properties b/android/gradle.properties index 38c8d454..19c6710d 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -2,3 +2,4 @@ org.gradle.jvmargs=-Xmx1536M android.enableR8=true android.useAndroidX=true android.enableJetifier=true +android.enableR8.fullMode=true \ No newline at end of file