MetaMask / metamask-android-sdk

MetaMask SDK for Android
Other
47 stars 13 forks source link

Proguard rules #151

Open S26T opened 3 weeks ago

S26T commented 3 weeks ago

Feature Request

I have critical crashes application at calling functions of Etherium class. After few hours I found solution.

Before (Enable R8, without adding rules)

FATAL EXCEPTION: DefaultDispatcher-worker-10 Process: <YOUR.APPLICATION.ID>, PID: 27609 java.lang.RuntimeException: Missing type parameter. at x6.a.<init>(SourceFile:10) at F7.j0.a(Unknown Source:91) at F7.f0.p(Unknown Source:29) at O7.a.r(Unknown Source:8) at o9.M.run(Unknown Source:112) at G.e.run(Unknown Source:28) at v9.j.run(Unknown Source:2) at v9.a.run(Unknown Source:95) Suppressed: t9.g: [z0{Cancelling}@23c1595, Dispatchers.IO]

After adding -keep class io.metamask.androidsdk.* { ; } I see this error

FATAL EXCEPTION: DefaultDispatcher-worker-7 Process: <YOUR.APPLICATION.ID>, PID: 28723 java.lang.RuntimeException: Missing type parameter. at com.google.gson.reflect.a.getSuperclassTypeParameter(Unknown Source:26) at com.google.gson.reflect.a.<init>(SourceFile:2) at io.metamask.androidsdk.SessionManager$getSessionConfig$type$1.<init>(Unknown Source:0) at io.metamask.androidsdk.SessionManager.getSessionConfig(Unknown Source:95) at io.metamask.androidsdk.SessionManager.getSessionConfig$default(Unknown Source:5) at io.metamask.androidsdk.SessionManager$1.invokeSuspend(Unknown Source:30) at K7.a.resumeWith(Unknown Source:8) at k9.N.run(Unknown Source:112) at G.e.run(Unknown Source:28) at r9.j.run(Unknown Source:2) at r9.a.run(Unknown Source:95) Suppressed: p9.g: [A0{Cancelling}@2957611, Dispatchers.IO]

After adding that rules it's okay

-keep class com.google.gson.reflect.TypeToken -keep class * extends com.google.gson.reflect.TypeToken -keep public class * implements java.lang.reflect.Type

Why it is needed

At enable R8 I have critical application crashes

Possible implementation

Correct working with R8

Code sample

-keep class com.google.gson.reflect.TypeToken -keep class extends com.google.gson.reflect.TypeToken -keep public class implements java.lang.reflect.Type