crisp-im / crisp-sdk-android

:package: Crisp Android SDK, add a chat in any Android app and communicate with your users.
https://docs.crisp.chat/guides/chatbox-sdks/android-sdk/
Other
55 stars 17 forks source link

Crisp progurd rules for full mode #96

Closed rezafaraji93 closed 2 years ago

rezafaraji93 commented 2 years ago

Would you please provide progurd rules for crisp?

rezafaraji93 commented 2 years ago

I am using R8 full mode and ANR happens because of Crisp

Doc1faux commented 2 years ago

Hi @rezafaraji93 and thank your for your feedback.

I didn't tested yet minification with R8 full mode as it was an experimental feature. However, I've just tested it and indeed it crashes... But this isn't due directly to our SDK but from Gson and Retrofit libraries. They miss to export proguard rules:

For Retrofit, from the 2.6.4 version we're using (to keep 4.4 compatibility) to the latest 2.9.0 release, they only export the following rules:

-keepattributes Signature
-if interface * { @retrofit2.http.* <methods>; }
-keep,allowobfuscation interface <1>

But more are needed according to their master branch, so the following ones should also be exported:

# 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

And if Kotlin is used, this one should be exported also:

# 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

So we end up exporting these proguard rules:

# Gson
-keep class com.google.gson.reflect.TypeToken { *; }
-keep class * extends com.google.gson.reflect.TypeToken
# Retrofit
-keep,allowobfuscation,allowshrinking interface retrofit2.Call
-keep,allowobfuscation,allowshrinking class retrofit2.Response
# Retrofit, only if Kotlin is used
-keep,allowobfuscation,allowshrinking class kotlin.coroutines.Continuation

I commited a fix for this but while waiting a new release, you already can apply these rules for your project, it should work ;)

Doc1faux commented 2 years ago

Fixed in 1.0.10 and released :)