Skip to content

Commit

Permalink
disabled minification due to retrofit issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Leonidius20 committed Jan 30, 2024
1 parent 8c3e43a commit c84f209
Show file tree
Hide file tree
Showing 6 changed files with 122 additions and 29 deletions.
14 changes: 10 additions & 4 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,16 @@ android {
useSupportLibrary = true
}

resourceConfigurations.addAll(listOf("en")) // only english resources


val keystoreFile = project.rootProject.file("secrets.properties")

if (keystoreFile.exists()) {
val secretProperties = Properties()
secretProperties.load(keystoreFile.inputStream())

val clientId = secretProperties.getProperty("SPOTIFY_CLIENT_ID") ?: ""
val clientId = secretProperties.getProperty("SPOTIFY_CLIENT_ID") ?: throw Exception("SPOTIFY_CLIENT_ID not set in secrets.properties")

buildConfigField("String", "SPOTIFY_CLIENT_ID", "\"$clientId\"")
} else {
Expand Down Expand Up @@ -70,8 +72,8 @@ android {

buildTypes {
release {
isMinifyEnabled = true
isShrinkResources = true
isMinifyEnabled = false // due to retrofit r8 issues
isShrinkResources = false
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
signingConfig = signingConfigs.getByName("release")
}
Expand Down Expand Up @@ -116,7 +118,7 @@ dependencies {

implementation("androidx.navigation:navigation-compose:$nav_version")

implementation("com.squareup.retrofit2:retrofit:2.9.0")
implementation("com.squareup.retrofit2:retrofit:2.10.0-SNAPSHOT")
// implementation("com.google.code.gson:gson:2.8.9")
implementation("com.squareup.retrofit2:converter-gson:2.9.0")

Expand All @@ -128,6 +130,10 @@ dependencies {

implementation("com.github.haroldadmin:NetworkResponseAdapter:5.0.0")

// https://mvnrepository.com/artifact/com.squareup.okhttp3/okhttp
implementation("com.squareup.okhttp3:okhttp:4.12.0")


implementation(project(":data"))

testImplementation("junit:junit:4.13.2")
Expand Down
78 changes: 77 additions & 1 deletion app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,80 @@

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
#-renamesourcefileattribute SourceFile
-printconfiguration ./build/app-full-r8-config.txt
-printusage ./build/app-full-r8-usage.txt
-printseeds ./build/app-full-r8-seeds.txt
-keepattributes LineNumberTable,SourceFile
-renamesourcefileattribute SourceFile


-dontobfuscate



















# 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.* <methods>;
}

# Ignore annotation used for build tooling.
-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement

# 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.* <methods>; }
-keep,allowobfuscation interface <1>

# 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

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

# With R8 full mode generic signatures are stripped for classes that are not kept.
-keep,allowobfuscation,allowshrinking class retrofit2.Response

Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class BeatInspectorApp: Application() {
.addConverterFactory(GsonConverterFactory. create())
.addCallAdapterFactory(NetworkResponseAdapterFactory())
.client(

OkHttpClient.Builder()
.addInterceptor(authInterceptor)
.build())
Expand Down
53 changes: 30 additions & 23 deletions data/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,36 @@
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile


-printconfiguration ./build/data-full-r8-config.txt
-printusage ./build/data-full-r8-usage.txt
-printseeds ./build/data-full-r8-seeds.txt
-keepattributes LineNumberTable,SourceFile
-renamesourcefileattribute SourceFile


-dontobfuscate





















# Retrofit does reflection on generic parameters. InnerClasses is required to use Signature and
# EnclosingMethod is required to use InnerClasses.
Expand Down Expand Up @@ -68,26 +98,3 @@

# With R8 full mode generic signatures are stripped for classes that are not kept.
-keep,allowobfuscation,allowshrinking class retrofit2.Response




# for 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.
-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.**


# FOR Its dependency
-dontwarn okio.**
4 changes: 3 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,6 @@ kotlin.code.style=official
# resources declared in the library itself and none from the library's dependencies,
# thereby reducing the size of the R class for that library
android.nonTransitiveRClass=true
org.gradle.unsafe.configuration-cache=true
org.gradle.unsafe.configuration-cache=true

android.enableR8.fullMode=false
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ dependencyResolutionManagement {
google()
mavenCentral()
maven("https://jitpack.io")
maven("https://s01.oss.sonatype.org/content/repositories/snapshots")
}
}

Expand Down

0 comments on commit c84f209

Please sign in to comment.