Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception "java.lang.Class cannot be cast to java.lang.reflect.ParameterizedType" launching Plaid handler when proguard/minify is enabled. #302

Open
vince-vendant opened this issue Feb 16, 2025 · 1 comment

Comments

@vince-vendant
Copy link

Repro

Kotlin app, build with:

        isMinifyEnabled = true

When this function is called

                    linkAccountToPlaid.launch(plaidHandler)

before a plaid UI appears, I see this exception.

java.lang.ClassCastException: java.lang.Class cannot be cast to java.lang.reflect.ParameterizedType
retrofit2.HttpServiceMethod.parseAnnotations(SourceFile:46)
retrofit2.ServiceMethod.parseAnnotations(SourceFile:39)
retrofit2.Retrofit.loadServiceMethod(SourceFile:202)
retrofit2.Retrofit$1.invoke(SourceFile:160)
java.lang.reflect.Proxy.invoke(Proxy.java:1006)
$Proxy3.a(Unknown Source)
com.plaid.internal.v4$a.invokeSuspend(SourceFile:6)
kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(SourceFile:33)
kotlinx.coroutines.DispatchedTask.run(SourceFile:108)
kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(SourceFile:115)
kotlinx.coroutines.scheduling.TaskImpl.run(SourceFile:103)
kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(SourceFile:584)
kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(SourceFile:793)
kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(SourceFile:697)
kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(SourceFile:684)
Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@f8e6efb, Dispatchers.Default]

Environment

Android OS Version e.g. 15.0.0 (35)
Android Devices/Emulators e.g. Pixel 9 Pro XL physical

Additional Info

Adding these lines to my proguard-rules.pro fixed the issue.

# 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

# 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
@vince-vendant
Copy link
Author

vince-vendant commented Feb 16, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant