Skip to content

Commit

Permalink
Enable proguard (#126)
Browse files Browse the repository at this point in the history
* Enable proguard

* do not remove unused resources due to corrupted/missing currency icons

* fix GroupCreateDialog cancel icon
  • Loading branch information
mdrlzy authored Oct 20, 2024
1 parent 9edf1f8 commit f81d529
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 7 deletions.
12 changes: 7 additions & 5 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,14 @@ android {
),
)
}

release {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro",
)
postprocessing {
isRemoveUnusedCode = true
isObfuscate = false
isOptimizeCode = true
proguardFiles("proguard-rules.pro")
}
signingConfig = signingConfigs.getByName("testRelease")

addManifestPlaceholders(
Expand Down
36 changes: 35 additions & 1 deletion app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,38 @@

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
#-renamesourcefileattribute SourceFile

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

# For using GSON @Expose annotation
-keepattributes *Annotation*

# Gson specific classes
-dontwarn sun.misc.**
#-keep class com.google.gson.stream.** { *; }

# Application classes that will be serialized/deserialized over Gson
-keep class com.google.gson.examples.android.model.** { <fields>; }

# 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 <fields>;
}

# 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

##---------------End: proguard configuration for Gson ----------
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package dev.arkbuilders.rate.data.network.dto

import androidx.annotation.Keep

@Keep
data class CryptoRateResponse(
val symbol: String,
val current_price: Double,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package dev.arkbuilders.rate.data.network.dto

import androidx.annotation.Keep

@Keep
data class FiatRateResponse(
val timestamp: Long,
val rates: Map<String, Double>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ fun GroupCreateDialogContent(
Modifier
.padding(end = 12.dp, top = 12.dp)
.align(Alignment.TopEnd),
onClick = {},
onClick = { onDismiss() },
) {
Icon(
modifier = Modifier,
Expand Down

0 comments on commit f81d529

Please sign in to comment.