diff --git a/app/build.gradle b/app/build.gradle index c901829a9e..a5e9a1350a 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -46,7 +46,7 @@ android { release { minifyEnabled true - proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" + proguardFiles getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro" signingConfig signingConfigs.release } diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index 6a3d447dcf..a87deef1de 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -19,10 +19,39 @@ # If you keep the line number information, uncomment this to # hide the original source file name. #-renamesourcefileattribute SourceFile --keepclassmembers enum * { *; } --keep class io.github.sds100.keymapper.** { *; } --keep interface io.github.sds100.keymapper.** { *; } +-keepclassmembers enum * { + public static **[] values(); + public static ** valueOf(java.lang.String); + } + +-keepattributes Signature + +# For using GSON @Expose annotation +-keepattributes *Annotation* + +# Gson specific classes +-dontwarn sun.misc.** +#-keep class com.google.gson.stream.** { *; } + +# Keep data entities so proguard doesn't break serialization/deserialization. +-keep class io.github.sds100.keymapper.data.entities.** { ; } + +# 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 -keep class com.google.android.material.** { *; }