Skip to content

Commit

Permalink
Update proguard rules for kotlin serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
yasinkacmaz committed Sep 26, 2024
1 parent 2db3704 commit 2de111d
Showing 1 changed file with 14 additions and 23 deletions.
37 changes: 14 additions & 23 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -14,37 +14,28 @@

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
-keepattributes SourceFile,LineNumberTable

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

# Kotlin Serialization: https://github.com/Kotlin/kotlinx.serialization#android
# General Kotlin Serialization rules
-keepattributes *Annotation*, InnerClasses
-dontnote kotlinx.serialization.AnnotationsKt

# Keep `Companion` object fields of serializable classes.
# This avoids serializer lookup through `getDeclaredClasses` as done for named companion objects.
-if @kotlinx.serialization.Serializable class **
-keepclassmembers class <1> {
static <1>$Companion Companion;
# Kotlinx Serialization JSON-specific rules
-keepclassmembers class kotlinx.serialization.json.** {
*** Companion;
}

# Keep `serializer()` on companion objects (both default and named) of serializable classes.
-if @kotlinx.serialization.Serializable class ** {
static **$* *;
}
-keepclassmembers class <2>$<3> {
-keepclasseswithmembers class kotlinx.serialization.json.** {
kotlinx.serialization.KSerializer serializer(...);
}

# Keep `INSTANCE.serializer()` of serializable objects.
-if @kotlinx.serialization.Serializable class ** {
public static ** INSTANCE;
}
-keepclassmembers class <1> {
public static <1> INSTANCE;
kotlinx.serialization.KSerializer serializer(...);
}
# Keep kotlinx.serialization internals
-keep class kotlinx.serialization.** { *; }

# @Serializable and @Polymorphic are used at runtime for polymorphic serialization.
-keepattributes RuntimeVisibleAnnotations,AnnotationDefault
# Keep classes annotated with @Serializable
-keepclassmembers class * {
@kotlinx.serialization.Serializable *;
}

0 comments on commit 2de111d

Please sign in to comment.