retrofit: Missing proguard rules for R8/AGP8, please make a 2.9.1 release including the retrofit.pro R8 full mode rules

What kind of issue is this?

  • Question. This issue tracker is not the place for questions. If you want to ask how to do something, or to understand why something isn’t working the way you expect it to, use Stack Overflow. https://stackoverflow.com/questions/tagged/retrofit

  • Bug report. If you’ve found a bug, spend the time to write a failing test. Bugs with tests get fixed. Here’s an example: https://gist.github.com/swankjesse/6608b4713ad80988cdc9

  • Feature Request. Start by telling us what problem you’re trying to solve. Often a solution already exists! Don’t send pull requests to implement new features without first getting our support. Sometimes we leave features out on purpose to keep the project small.

After upgrading to AGP 8, release build are crashing on :

java.lang.IllegalArgumentException: Call return type must be parameterized as Call<Foo> or Call<? extends Foo>
                                                                                                    	at oe.i.a(SourceFile:43)
                                                                                                    	at oe.d0.d(SourceFile:36)
                                                                                                    	at oe.d0.a(Unknown Source:1)
                                                                                                    	at oe.m.d(SourceFile:1)

from R8 mapping :

retrofit2.DefaultCallAdapterFactory -> oe.i:
# {"id":"sourceFile","fileName":"DefaultCallAdapterFactory.java"}
    java.util.concurrent.Executor callbackExecutor -> a
    1:3:void <init>(java.util.concurrent.Executor):31:31 -> <init>
    4:6:void <init>(java.util.concurrent.Executor):32:32 -> <init>

This happens with :

  • implementation 'com.squareup.retrofit2:retrofit:2.7.2'
    
  • implementation 'com.squareup.retrofit2:retrofit:2.9.0'
    

Looking at the repo I saw that the https://github.com/square/retrofit/blob/master/retrofit/src/main/resources/META-INF/proguard/retrofit2.pro contains more rules than the one that are include in the retrofit jar. So I tried to add the content of https://github.com/square/retrofit/blob/master/retrofit/src/main/resources/META-INF/proguard/retrofit2.pro to my proguard.pro file and it solves the problem.

Is it possible to release a 2.9.1 version that includes the missing rules, especially the R8 full mode ones ?

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 36
  • Comments: 18 (6 by maintainers)

Most upvoted comments

The only additional rule you need to add manually for now is the one added in commit 59d302a.

Hopefully within a week! But maybe two…

I also just ran into this issue. For anyone else, until the issue is fixed, if you are using a non-default call adapter factory, you must also add the rules from it. For example, I am using the rxjava2 call adapter factory, so I needed to add the rules here: https://github.com/square/retrofit/blob/master/retrofit-adapters/rxjava2/src/main/resources/META-INF/proguard/retrofit2-rxjava2-adapter.pro

No. Still planned.

What kind of issue is this?

  • Question. This issue tracker is not the place for questions. If you want to ask how to do something, or to understand why something isn’t working the way you expect it to, use Stack Overflow. https://stackoverflow.com/questions/tagged/retrofit
  • Bug report. If you’ve found a bug, spend the time to write a failing test. Bugs with tests get fixed. Here’s an example: https://gist.github.com/swankjesse/6608b4713ad80988cdc9
  • Feature Request. Start by telling us what problem you’re trying to solve. Often a solution already exists! Don’t send pull requests to implement new features without first getting our support. Sometimes we leave features out on purpose to keep the project small.

After upgrading to AGP 8, release build are crashing on :

java.lang.IllegalArgumentException: Call return type must be parameterized as Call<Foo> or Call<? extends Foo>
                                                                                                    	at oe.i.a(SourceFile:43)
                                                                                                    	at oe.d0.d(SourceFile:36)
                                                                                                    	at oe.d0.a(Unknown Source:1)
                                                                                                    	at oe.m.d(SourceFile:1)

from R8 mapping :

retrofit2.DefaultCallAdapterFactory -> oe.i:
# {"id":"sourceFile","fileName":"DefaultCallAdapterFactory.java"}
    java.util.concurrent.Executor callbackExecutor -> a
    1:3:void <init>(java.util.concurrent.Executor):31:31 -> <init>
    4:6:void <init>(java.util.concurrent.Executor):32:32 -> <init>

This happens with :

  • implementation 'com.squareup.retrofit2:retrofit:2.7.2'
    
  • implementation 'com.squareup.retrofit2:retrofit:2.9.0'
    

Looking at the repo I saw that the https://github.com/square/retrofit/blob/master/retrofit/src/main/resources/META-INF/proguard/retrofit2.pro contains more rules than the one that are include in the retrofit jar. So I tried to add the content of https://github.com/square/retrofit/blob/master/retrofit/src/main/resources/META-INF/proguard/retrofit2.pro to my proguard.pro file and it solves the problem.

Is it possible to release a 2.9.1 version that includes the missing rules, especially the R8 full mode ones ?

Did you add all the content in https://github.com/square/retrofit/blob/master/retrofit/src/main/resources/META-INF/proguard/retrofit2.pro ? I added the one’s which mentioned R8 full, it didn’t fix my issue.