plaid / plaid-link-android

Plaid Link Android SDK
https://plaid.com/docs/link/android
MIT License
114 stars 48 forks source link

Missing type parameter crash with SDK 4.1.1 on Proguard build #262

Closed marceltex closed 6 months ago

marceltex commented 7 months ago

The problem

When using version 4.1.1 of the SDK, the flow causes an app crash as soon as it tries to launch when using a build that has been obfuscated with Proguard. No crash seen when using a debug build.

The Plaid Link loading spinner is displayed for a second or two and then the app crashes. See log below.

Nothing changed in our app's source code except updating the Plaid SDK to 4.1.1. No crash was happening when using Plaid Link SDK 4.0.0.

Environment

Android OS Version 14.0.0 (34)
Android Device Pixel 8 (Physical)

Steps to Reproduce

Launch the Plaid Link SDK version 4.1.1 on Proguard obfuscated build of app.

Expected Result

The first screen of the flow should be shown.

Logs

java.lang.RuntimeException: Missing type parameter.
    at com.google.gson.reflect.TypeToken.getSuperclassTypeParameter(SourceFile:84)
    at com.google.gson.reflect.TypeToken.<init>(SourceFile:62)
    at com.plaid.internal.h2.<init>(SourceFile:1)
    at com.plaid.internal.core.crashreporting.internal.a.<init>(SourceFile:7)
    at com.plaid.internal.core.crashreporting.internal.a$a.a(SourceFile:2)
    at com.plaid.internal.ob.<init>(SourceFile:23)
    at com.plaid.internal.qc.get(SourceFile:84)
    at dagger.internal.DoubleCheck.get(SourceFile:47)
    at com.plaid.link.Plaid$setLinkEventListener$2.invoke(SourceFile:4)
    at com.plaid.link.Plaid$setLinkEventListener$2.invoke(SourceFile:1)
    at com.plaid.internal.z6$a.invokeSuspend(SourceFile:3)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(SourceFile:33)
    at kotlinx.coroutines.DispatchedTask.run(SourceFile:108)
    at android.os.Handler.handleCallback(Handler.java:942)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loopOnce(Looper.java:240)
    at android.os.Looper.loop(Looper.java:351)
    at android.app.ActivityThread.main(ActivityThread.java:8423)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:584)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1013)
    Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@1563147, Dispatchers.Default]
melissaosullivan commented 7 months ago

Hi @marceltex,

Could you try adding the following to your app's proguard-rules.pro:

-keep,allowobfuscation,allowshrinking class com.google.gson.reflect.TypeToken
-keep,allowobfuscation,allowshrinking class * extends com.google.gson.reflect.TypeToken

If that doesn't work could you please share the following info for your project:

  1. Kotlin version
  2. Android Gradle Plugin version
  3. Gradle version
  4. R8/proguard version
  5. If proguard fullmode is enabled

Thanks.

marceltex commented 7 months ago

@melissaosullivan Thank you for replying so quickly!

Sorry for the delay in my response.

I just tested and adding the Proguard rules you suggested fixes the crash. Thank you!

marceltex commented 7 months ago

Quick follow up question, will these rules be added to the consumer-rules.pro of the Plaid Link Android library in a future release, so that developers using the library don't have to manually add these rules to their app's Proguard rules file, or is there no plan to add these rules to consumer-rules.pro?

melissaosullivan commented 6 months ago

These rules have been added to 4.2.0. Thanks!