I have this code:
val profile: UserProfile = userApi.profile()
@GET("users/profile")
suspend fun profile(): UserProfile
When i run userApi.profile() i get this error:
java.lang.ClassCastException: java.lang.Class cannot be cast to java.lang.reflect.ParameterizedType
Details: I updated gradle, some libraries, kotlin version and android studio. This code used to work before updates. Nothing changed on backend side.
Update: looks like this is happening to all api calls, not just this one.
retrofitVersion = 2.9.0
kotlinVersion = 1.8.10
gradle = 8.0
If you check this link https://github.com/square/retrofit/issues/3751 it will tell you to add these in your proguard-rules.pro
file
# 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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With