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

After enable R8 full mode getting ParameterizedType error #100

Closed
proninyaroslav opened this issue Apr 16, 2023 · 7 comments · Fixed by #103
Closed

After enable R8 full mode getting ParameterizedType error #100

proninyaroslav opened this issue Apr 16, 2023 · 7 comments · Fixed by #103
Assignees

Comments

@proninyaroslav
Copy link

Please complete the following information:

  • Library Version: 1.3.5

Describe the Bug:

This issue is similar to the issue in Retrofit (square/retrofit#3751) but I'm not sure, but I've duplicated it here. This happens with AGP 8.0. As a solution, it's proposed to add these proguard lines to the project (square/retrofit#3751 (comment)):

 # 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 

but it doesn't actually work, After adding this proguard lines I get a slightly different error:

 java.lang.IllegalArgumentException: Unable to create call adapter for retrofit2.Call<com.skydoves.sandwich.ApiResponse>
                     for method ComicVineService.issues
                 	at retrofit2.Utils.methodError(SourceFile:47)
                 	at retrofit2.HttpServiceMethod.parseAnnotations(SourceFile:394)
                 	at retrofit2.Retrofit.loadServiceMethod(SourceFile:31)
                 	at retrofit2.Retrofit$1.invoke(SourceFile:45)
                 	at java.lang.reflect.Proxy.invoke(Proxy.java:1006)
                 	at $Proxy9.issues(Unknown Source)
                        ...
Caused by: java.lang.ClassCastException: java.lang.Class cannot be cast to java.lang.reflect.ParameterizedType
                 	at com.skydoves.sandwich.adapters.ApiResponseCallAdapterFactory.get(SourceFile:53)
                 	at retrofit2.Retrofit.callAdapter(SourceFile:33)
                 	at retrofit2.HttpServiceMethod.parseAnnotations(SourceFile:375)
                 	... 41 more
 @GET("issues?format=$FORMAT&field_list=${Fields.Issues}")
    @JvmSuppressWildcards
    suspend fun issues(
        @Query("api_key") apiKey: String,
        @Query("offset") offset: Int,
        @Query("limit") limit: Int,
        @Query("sort", encoded = true) sort: ComicVineSort?,
        @Query("filter[]", encoded = true) filter: List<ComicVineFilter>?,
    ): ApiResponse<IssuesResponse>
@nonproto
Copy link

nonproto commented Nov 8, 2023

I started getting this again with 2.0.0

@skydoves
Copy link
Owner

skydoves commented Nov 8, 2023

@CarlosEsco Thanks for reporting this issue. Would you add the proguard rule for now? Let me check out the issue on 2.0.0 soon.

# R8 full mode strips signatures from non-kept items.
-keep,allowobfuscation,allowshrinking interface com.skydoves.sandwich.ApiResponse

@skydoves
Copy link
Owner

skydoves commented Nov 9, 2023

@CarlosEsco Would you check if it works well with the 2.0.1-SNAPSHOT?

@ivaniskandar
Copy link

I've had the same issue and I can confirm the rule above works with 2.0.2

@skydoves
Copy link
Owner

@ivaniskandar It would be appreciated if you could check does the rule above works along with 2.0.2.

@ivaniskandar
Copy link

Yes it works with 2.0.2

@skydoves
Copy link
Owner

@ivaniskandar Thanks for checking it. The new release 2.0.3 contains the proguard rules, and it must work well without add the rules manually.

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

Successfully merging a pull request may close this issue.

4 participants