-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Open
Description
Bit of an edge case here—but if all of the functions in a Retrofit interface are unused, R8 will strip them. This causes the following Proguard rule to miss:
| -if interface * { @retrofit2.http.* <methods>; } |
Then once you try to instantiate the stripped service class, you get a fairly nondescript ClassCastException from Retrofit. E.g.:
Caused by: java.lang.ClassCastException
at androidx.appcompat.app.ToolbarActionBar$$ExternalSyntheticThrowCCEIfNotNull0.m(:0)
Replacing the referenced rule with the following one fixes the issue for us:
-if interface *
-keepclasseswithmembers,allowobfuscation interface <1> {
@retrofit2.http.* <methods>;
}
(Source: here)
Note: I barely know how to proguard, so this definitely requires some scrutiny. Raising issue here for visibility.
Endeavour233, audkar, MichelangeloNinja, scottschmitz, kmayoral and 3 more
Metadata
Metadata
Assignees
Labels
No labels