Skip to content

Add Proguard consumer rules for Retrofit #62

Description

@lukaszkalnik

When using Proguard/R8, our app crashes with Flagsmith with the following exception:

FATAL EXCEPTION: main
Process: redacted, PID: 22008
 java.lang.IllegalArgumentException: Unable to create call adapter for interface N7.c
    for method c.a
	at N7.X.j(Unknown Source:39)
	at N7.o.a(Unknown Source:2792)
	at N7.Q.invoke(Unknown Source:102)
	at java.lang.reflect.Proxy.invoke(Proxy.java:1006)
	at $Proxy1.a(Unknown Source)
	at redacted.RemoteConfig$Companion.init$redacted(Unknown Source:120)
	at redacted.doSetup(Unknown Source:85)
	at redacted.MyApplication$onCreate$1.invokeSuspend(Unknown Source:47)
	at o6.a.resumeWith(Unknown Source:8)
	at kotlinx.coroutines.DispatchedTask.run(Unknown Source:108)
	at android.os.Handler.handleCallback(Handler.java:883)
	at android.os.Handler.dispatchMessage(Handler.java:100)
	at android.os.Looper.loop(Looper.java:214)
	at android.app.ActivityThread.main(ActivityThread.java:7397)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:935)
	Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@a0ae3d4, Dispatchers.Main]
Caused by: java.lang.IllegalArgumentException: Call return type must be parameterized as Call<Foo> or Call<? extends Foo>
	at N7.n.a(Unknown Source:44)
	at C.h.l(Unknown Source:34)
	at N7.o.a(Unknown Source:2627)
	... 15 more

It works however after adding the following rules (we don't use Retrofit otherwise, that's why we have to add them specifically for Flagsmith):

-if interface * { @retrofit2.http.* <methods>; }
-keep,allowobfuscation interface <1>
-keep,allowobfuscation,allowshrinking interface retrofit2.Call
-keep,allowobfuscation,allowshrinking class retrofit2.Response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions