From 367e84c88114958ed6a41f0adcd334ded1f059a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolo=CC=80=20Tosi?= Date: Wed, 20 Dec 2023 11:51:41 +0100 Subject: [PATCH] - Disabled R8 full mode (default for AGP 8.x) - Updated GSON proguard rules --- app/proguard-rules.pro | 37 ++++++++++++++++++++++++++++--------- gradle.properties | 4 +++- 2 files changed, 31 insertions(+), 10 deletions(-) diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index abc06636..9b2f4ed1 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -12,20 +12,39 @@ # public *; #} -# Uncomment this to preserve the line number information for -# debugging stack traces. -#-keepattributes SourceFile,LineNumberTable - # Get deobfuscated crash reports with the Firebase Crashlytics SDK -keepattributes SourceFile,LineNumberTable # Keep file names and line numbers. -keep public class * extends java.lang.Exception # Optional: Keep custom exceptions. -# If you keep the line number information, uncomment this to -# hide the original source file name. -#-renamesourcefileattribute SourceFile +##---------------Begin: proguard configuration for Gson ---------- +# 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.** +#-keep class com.google.gson.stream.** { *; } +# 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 ; - @com.google.gson.annotations.Expose ; + @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 ---------- diff --git a/gradle.properties b/gradle.properties index 98bed167..177c225c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -18,4 +18,6 @@ android.useAndroidX=true # Automatically convert third-party libraries to use AndroidX android.enableJetifier=true # Kotlin code style for this project: "official" or "obsolete": -kotlin.code.style=official \ No newline at end of file +kotlin.code.style=official +# R8 full mode is enabled by default in AGP 8.x. +android.enableR8.fullMode=false