From 7bd690b7540f69621e5f0d4c7afd935f7cece022 Mon Sep 17 00:00:00 2001 From: nijuyonkadesu <24ksriramv@gmail.com> Date: Fri, 14 Jul 2023 21:55:40 +0530 Subject: [PATCH] fixes #8 added proguard rules --- app/build.gradle | 6 +++ app/proguard-rules.pro | 93 +++++++++++++++++++++++++++++++++++++++++- 2 files changed, 98 insertions(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index 9165119..fcb54d1 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -27,6 +27,12 @@ android { minifyEnabled true proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } + prerelease { + // Testing configuration + debuggable true + minifyEnabled true // Disable minification for easier debugging + applicationIdSuffix ".testing" // Add a suffix to the application ID for differentiation + } } compileOptions { sourceCompatibility JavaVersion.VERSION_17 diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index 481bb43..bfb0d3d 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -18,4 +18,95 @@ # If you keep the line number information, uncomment this to # hide the original source file name. -#-renamesourcefileattribute SourceFile \ No newline at end of file +#-renamesourcefileattribute SourceFile + +-keep class one.njk.sao.models.Waifu { *; } +-keep class one.njk.sao.models.Waifus { *; } + +-keep,allowobfuscation,allowshrinking class one.njk.sao.data.ApiResult + +# RetroFit +# AGP 8.0 uses full R8 by default +# Keep generic signature of Call, Response (R8 full mode strips signatures from non-kept items). +-keep,allowobfuscation,allowshrinking interface retrofit2.Call +-keep,allowobfuscation,allowshrinking class retrofit2.Response + +# With R8 full mode generic signatures are stripped for classes that are not +# kept. Suspend functions are wrapped in continuations where the type argument +# is used. +-keep,allowobfuscation,allowshrinking class kotlin.coroutines.Continuation +-keep,allowobfuscation,allowshrinking class com.squareup.moshi.kotlin.reflect.KotlinJsonAdapter + +# https://github.com/square/retrofit/issues/3751 +-keepclassmembers class one.njk.sao.models.Waifu { +@com.squareup.moshi.FromJson *; +@com.squareup.moshi.ToJson *; +} + +-keepclassmembers class one.njk.sao.models.Waifus { +@com.squareup.moshi.FromJson *; +@com.squareup.moshi.ToJson *; +} + +# Retrofit's Rules + +# Retrofit does reflection on generic parameters. InnerClasses is required to use Signature and +# EnclosingMethod is required to use InnerClasses. +-keepattributes Signature, InnerClasses, EnclosingMethod + +# Retrofit does reflection on method and parameter annotations. +-keepattributes RuntimeVisibleAnnotations, RuntimeVisibleParameterAnnotations + +# Keep annotation default values (e.g., retrofit2.http.Field.encoded). +-keepattributes AnnotationDefault + +# Retain service method parameters when optimizing. +-keepclassmembers,allowshrinking,allowobfuscation interface * { + @retrofit2.http.* ; +} + + +# Ignore JSR 305 annotations for embedding nullability information. +-dontwarn javax.annotation.** + +# Guarded by a NoClassDefFoundError try/catch and only used when on the classpath. +-dontwarn kotlin.Unit + +# Top-level functions that can only be used by Kotlin. +-dontwarn retrofit2.KotlinExtensions +-dontwarn retrofit2.KotlinExtensions$* + +# With R8 full mode, it sees no subtypes of Retrofit interfaces since they are created with a Proxy +# and replaces all potential values with null. Explicitly keeping the interfaces prevents this. +-if interface * { @retrofit2.http.* ; } +-keep,allowobfuscation interface <1> + +# Keep inherited services. +-if interface * { @retrofit2.http.* ; } +-keep,allowobfuscation interface * extends <1> + +# With R8 full mode generic signatures are stripped for classes that are not +# kept. Suspend functions are wrapped in continuations where the type argument +# is used. +-keep,allowobfuscation,allowshrinking class kotlin.coroutines.Continuation + +# R8 full mode strips generic signatures from return types if not kept. +-if interface * { @retrofit2.http.* public *** *(...); } +-keep,allowoptimization,allowshrinking,allowobfuscation class <3> + + +# Okio +# JSR 305 annotations are for embedding nullability information. +-dontwarn javax.annotation.** + +# A resource is loaded with a relative path so the package of this class must be preserved. +-adaptresourcefilenames okhttp3/internal/publicsuffix/PublicSuffixDatabase.gz + +# Animal Sniffer compileOnly dependency to ensure APIs are compatible with older versions of Java. +-dontwarn org.codehaus.mojo.animal_sniffer.* + +# OkHttp platform used only on JVM and when Conscrypt and other security providers are available. +-dontwarn okhttp3.internal.platform.** +-dontwarn org.conscrypt.** +-dontwarn org.bouncycastle.** +-dontwarn org.openjsse.**