From 9591f4e14f92466abe0465b34b8da2f290e79cce Mon Sep 17 00:00:00 2001 From: CnC-Robert Date: Sun, 4 Jun 2023 19:37:23 +0200 Subject: [PATCH] feat: ProGuard --- app/build.gradle.kts | 3 ++- app/proguard-rules.pro | 55 +++++++++++++++++++++++++++++++++--------- 2 files changed, 45 insertions(+), 13 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 7db4866e11..826a072ec2 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -23,7 +23,8 @@ android { buildTypes { release { - isMinifyEnabled = false + isMinifyEnabled = true + isShrinkResources = true proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") } } diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index d99b33c9e4..c1069ecd7a 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -5,17 +5,48 @@ # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html -# If your project uses WebView with JS, uncomment the following -# and specify the fully qualified class name to the JavaScript interface -# class: -#-keepclassmembers class fqcn.of.javascript.interface.for.webview { -# public *; -#} +-dontobfuscate -# Uncomment this to preserve the line number information for -# debugging stack traces. -#-keepattributes SourceFile,LineNumberTable +# Required for serialization to work properly +-if @kotlinx.serialization.Serializable class ** +-keepclassmembers class <1> { + static <1>$Companion Companion; +} +-if @kotlinx.serialization.Serializable class ** { + static **$* *; +} +-keepclassmembers class <2>$<3> { + kotlinx.serialization.KSerializer serializer(...); +} +-if @kotlinx.serialization.Serializable class ** { + public static ** INSTANCE; +} +-keepclassmembers class <1> { + public static <1> INSTANCE; + kotlinx.serialization.KSerializer serializer(...); +} -# If you keep the line number information, uncomment this to -# hide the original source file name. -#-renamesourcefileattribute SourceFile \ No newline at end of file +# Required for the patcher to function correctly +-keep class app.revanced.patcher.** { + *; +} +-keep class brut.** { + *; +} +-keep class org.xmlpull.** { + *; +} +-keep class kotlin.** { + *; +} +-keep class org.jf.** { + *; +} +-keep class com.android.** { + *; +} +-dontwarn java.awt.** +-dontwarn javax.** +-dontwarn org.slf4j.** + +-keepattributes RuntimeVisibleAnnotations,AnnotationDefault \ No newline at end of file