Skip to content

[FEAT] Add proguard rules to documentation to help devs when releasing their final apps #13

@sir-mury

Description

@sir-mury

Hi team,
While integrating paystack_flutter_sdk into a Flutter app, I ran into runtime errors due to R8/ProGuard stripping essential classes used internally by Retrofit and OkHttp.

After investigation, I figured out a set of ProGuard rules that resolve the issue and allow verifyAccessCode and other SDK methods to work correctly in release mode.

I think it would be helpful to other developers if these rules were included in the official documentation or README.

Here's the working snippet:

Kotlin serialization

-keepattributes Annotation, InnerClasses
-dontnote kotlinx.serialization.AnnotationsKt
-keepclassmembers class kotlinx.serialization.json.** {
*** Companion;
}
-keepclasseswithmembers class kotlinx.serialization.json.** {
kotlinx.serialization.KSerializer serializer(...);
}

Kotlin general

-keep class kotlin.** { ; }
-keep class kotlinx.
* { *; }
-keepclassmembers class **$WhenMappings {
;
}
-keepclassmembers class kotlin.Metadata {
public ;
}

Keep Kotlin Parcelize

-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}
-keepnames class * implements android.os.Parcelable {
public static final ** CREATOR;
}
-keepclassmembers class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}

Keep Retrofit core classes

-keep interface retrofit2.Call
-keep class retrofit2.** { ; }
-keep interface retrofit2.
* { *; }
-keepattributes Signature
-keepattributes Annotation

-keep class com.squareup.retrofit2.** { ; }
-keep interface com.squareup.retrofit2.
* { ; }
-keepclasseswithmembers class * {
@retrofit2.http.
;
}

-keep class com.paystack.android.core.api.** { ; }
-keep interface com.paystack.android.core.api.
* { ; }
-keep class com.paystack.android.core.api.models.
* {*;}
-keepattributes Signature
-keepattributes Annotation

I can drop a PR if preffered

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions