Skip to content

Commit

Permalink
update proguard
Browse files Browse the repository at this point in the history
  • Loading branch information
crackededed committed Feb 21, 2024
1 parent 2c7a6e8 commit f39a09f
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 103 deletions.
8 changes: 6 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ android {
minSdk = 16
targetSdk = 34
versionCode = 121
versionName = "2.29.0"
versionName = "2.29.1"
resourceConfigurations += listOf("ar", "de", "en", "es", "fr", "in", "ja", "pt-rBR", "ru", "tr", "zh-rTW", "zh-rCN")
}

Expand Down Expand Up @@ -61,9 +61,11 @@ android {
"androidx.lifecycle:lifecycle-viewmodel-ktx:2.7.0-alpha03",
"androidx.webkit:webkit:1.9.0-alpha01",
"com.google.android.material:material:1.11.0",
"com.squareup.okhttp3:okhttp:3.12.13",
"com.squareup.okhttp3:logging-interceptor:3.12.13",
"com.squareup.retrofit2:retrofit:2.6.4",
"com.squareup.retrofit2:converter-gson:2.6.4",
"com.google.code.gson:gson:2.9.1",
))
}
}
Expand Down Expand Up @@ -100,9 +102,11 @@ dependencies {
implementation(libs.webkit)

//Misc
implementation(libs.okhttp)
implementation(libs.okhttp.logging)
implementation(libs.retrofit)
implementation(libs.retrofit.converter.gson)
implementation(libs.okhttp.logging.interceptor)
implementation(libs.gson)

implementation(libs.fetch)
implementation(libs.fetch.okhttp)
Expand Down
126 changes: 28 additions & 98 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -20,65 +20,41 @@
# hide the original source file name.
#-renamesourcefileattribute SourceFile

-dontwarn com.github.andreyasadchy.xtra.ui.**
-keep class com.iheartradio.m3u8.** { *; }
-assumenosideeffects class android.util.Log {
public static *** d(...);
public static *** v(...);
}

-keep class com.woxthebox.draglistview.** { *; }

# https://github.com/google/conscrypt/blob/master/android/proguard-rules.pro
-dontwarn com.android.org.conscrypt.SSLParametersImpl
-dontwarn org.apache.harmony.xnet.provider.jsse.SSLParametersImpl

-dontwarn okhttp3.internal.Util
-dontwarn okhttp3.internal.annotations.EverythingIsNonNull
# https://github.com/square/retrofit/blob/trunk/retrofit/src/main/resources/META-INF/proguard/retrofit2.pro
# Keep annotation default values (e.g., retrofit2.http.Field.encoded).
-keepattributes AnnotationDefault

# https://github.com/square/retrofit/issues/3751
# 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
# Keep inherited services.
-if interface * { @retrofit2.http.* <methods>; }
-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

-keep class com.woxthebox.draglistview.** { *; }

-keep public class com.bumptech.glide.integration.webp.WebpImage { *; }
-keep public class com.bumptech.glide.integration.webp.WebpFrame { *; }
-keep public class com.bumptech.glide.integration.webp.WebpBitmapFactory { *; }

-keep public class * implements com.bumptech.glide.module.GlideModule
-keep class * extends com.bumptech.glide.module.AppGlideModule {
<init>(...);
}
-keep public enum com.bumptech.glide.load.ImageHeaderParser$** {
**[] $VALUES;
public *;
}
-keep class com.bumptech.glide.load.data.ParcelFileDescriptorRewinder$InternalRewinder {
*** rewind();
}

-keepclassmembernames class kotlinx.** {
volatile <fields>;
}

-keepclassmembers class com.google.android.exoplayer2.source.hls.playlist.DefaultHlsPlaylistTracker {
<methods>;
}

-keepclassmembers enum com.iheartradio.m3u8.data.** {
*;
}

-forceprocessing
# R8 full mode strips generic signatures from return types if not kept.
-if interface * { @retrofit2.http.* public *** *(...); }
-keep,allowoptimization,allowshrinking,allowobfuscation class <3>

-assumenosideeffects class android.util.Log {
public static *** d(...);
public static *** v(...);
}
# With R8 full mode generic signatures are stripped for classes that are not kept.
-keep,allowobfuscation,allowshrinking class retrofit2.Response

# https://github.com/google/gson/blob/main/examples/android-proguard-example/proguard.cfg
##---------------Begin: proguard configuration for Gson ----------
# Gson uses generic type information stored in a class file when working with fields. Proguard
# removes such information by get, so configure it to keep all of it.
# removes such information by default, so configure it to keep all of it.
-keepattributes Signature

# For using GSON @Expose annotation
Expand All @@ -92,66 +68,20 @@
# Application classes that will be serialized/deserialized over Gson
-keep class com.github.andreyasadchy.xtra.model.** { *; }

# Prevent proguard from stripping interface information from TypeAdapterFactory,
# 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

##---------------End: proguard configuration for Gson ----------

##OkHttp
# 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.
-keepnames class okhttp3.internal.publicsuffix.PublicSuffixDatabase
# 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 dependency is available.
-dontwarn okhttp3.internal.platform.ConscryptPlatform

# http://stackoverflow.com/questions/29679177/cardview-shadow-not-appearing-in-lollipop-after-obfuscate-with-proguard/29698051
-keep class androidx.cardview.widget.RoundRectDrawable { *; }

# Retrofit 2.X
## https://square.github.io/retrofit/ ##
-dontwarn retrofit2.**
-keep class retrofit2.** { *; }
-keepattributes Signature
-keepattributes Exceptions
-keepclasseswithmembers class * {
@retrofit2.http.* <methods>;
}

# Dagger ProGuard rules.
# https://github.com/square/dagger
-dontwarn dagger.internal.codegen.**
# Prevent R8 from leaving Data object members always null
-keepclassmembers,allowobfuscation class * {
@javax.inject.* *;
@dagger.* *;
<init>();
}
-keep class dagger.* { *; }
-keep class javax.inject.* { *; }
-keep class * extends dagger.internal.Binding
-keep class * extends dagger.internal.ModuleAdapter
-keep class * extends dagger.internal.StaticInjection

-keep public class androidx.appcompat.widget.widget.** { *; }
-keep public class androidx.preference.internal.** { *; }
-keep public class * extends androidx.core.view.ActionProvider {
public <init>(android.content.Context);
@com.google.gson.annotations.SerializedName <fields>;
}

-keepclasseswithmembernames class * {
native <methods>;
}
# 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

#Kotlin coroutines
-keepnames class kotlinx.coroutines.internal.MainDispatcherFactory {}
-keepnames class kotlinx.coroutines.CoroutineExceptionHandler {}
-keepnames class kotlinx.coroutines.android.AndroidExceptionPreHandler {}
-keepnames class kotlinx.coroutines.android.AndroidDispatcherFactory {}
-keepclassmembernames class kotlinx.** {
volatile <fields>;
}
##---------------End: proguard configuration for Gson ----------
9 changes: 6 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ checker-qual = "3.42.0"
coil = "2.5.0"
constraintlayout = "2.1.4"
core = "1.12.0"
coroutines = "1.7.3"
coroutines = "1.8.0"
draglistview = "1.7.3"
fetch = "3.1.6"
flexbox = "3.0.0"
fragment = "1.6.2"
glide = "4.16.0"
glide-webpdecoder = "2.6.4.16.0"
gson = "2.10.1"
hilt = "2.50"
hilt-extension-compiler = "1.1.0"
hilt-work = "1.1.0"
Expand All @@ -21,7 +22,7 @@ ksp = "1.9.22-1.0.17"
lifecycle = "2.7.0"
material = "1.11.0"
media3 = "1.2.1"
navigation = "2.7.6"
navigation = "2.7.7"
okhttp = "5.0.0-alpha.12"
open-m3u8 = "0.2.6"
paging = "3.2.1"
Expand Down Expand Up @@ -50,6 +51,7 @@ glide = { module = "com.github.bumptech.glide:glide", version.ref = "glide" }
glide-ksp = { module = "com.github.bumptech.glide:ksp", version.ref = "glide" }
glide-okhttp = { module = "com.github.bumptech.glide:okhttp3-integration", version.ref = "glide" }
glide-webpdecoder = { module = "com.github.zjupure:webpdecoder", version.ref = "glide-webpdecoder" }
gson = { module = "com.google.code.gson:gson", version.ref = "gson" }
hilt = { module = "com.google.dagger:hilt-android", version.ref = "hilt" }
hilt-compiler = { module = "com.google.dagger:hilt-compiler", version.ref = "hilt" }
hilt-extension-compiler = { module = "androidx.hilt:hilt-compiler", version.ref = "hilt-extension-compiler" }
Expand All @@ -66,7 +68,8 @@ media3-session = { module = "androidx.media3:media3-session", version.ref = "med
media3-ui = { module = "androidx.media3:media3-ui", version.ref = "media3" }
navigation-fragment-ktx = { module = "androidx.navigation:navigation-fragment-ktx", version.ref = "navigation" }
navigation-ui-ktx = { module = "androidx.navigation:navigation-ui-ktx", version.ref = "navigation" }
okhttp-logging-interceptor = { module = "com.squareup.okhttp3:logging-interceptor", version.ref = "okhttp" }
okhttp = { module = "com.squareup.okhttp3:okhttp", version.ref = "okhttp" }
okhttp-logging = { module = "com.squareup.okhttp3:logging-interceptor", version.ref = "okhttp" }
open-m3u8 = { module = "com.iheartradio.m3u8:open-m3u8", version.ref = "open-m3u8" }
paging-runtime-ktx = { module = "androidx.paging:paging-runtime-ktx", version.ref = "paging" }
preference-ktx = { module = "androidx.preference:preference-ktx", version.ref = "preference" }
Expand Down

0 comments on commit f39a09f

Please sign in to comment.