Reputation: 2359
I am using an external library(Picasso) from Jcenter in my Android application. I am implementing an interface of that library in my app. The problem is that proguard always strips the methods of the implemented interface in my app.
The interface defined in the external library is
public interface Callback {
void onSuccess();
void onError();
}
And i implement this interface in my code. When i run proguard and check my .class files, i find that there are no onSuccess
and onError
methods in my implemented class.
I have already added the configurations to skip all that external library completely in my proguard file by adding this
-keep class com.squareup.picasso.** {*;}
-dontwarn com.squareup.picasso.**
One way of preventing the above stripping is that i do this, where PicassoCallback
is my implementation of Callback
interface
-keep class com.package.className$PicassoCallback{
public void onSuccess();
public void onError();
}
But then i will have to do this for every implementation of the external interface in my project.
Any proguard configuration that can help me to prevent stripping the methods throughout my project?
Upvotes: 0
Views: 2202
Reputation: 8188
You can configure ProGuard to keep all classes that implement the Callback
interface using this rule:
-keep class ** implements com.squareup.picasso.Callback { *; }
Another way is to add the @Keep
annotation to all of you callbacks, which basically tells ProGuard to not strip/modify them in any way.
Upvotes: 3
Reputation: 1
Just add this line:
-keep interface com.squareup.picasso.** { *; }
after this one:
-keep class com.squareup.picasso.** {*;}
I use several squareup libs so I have the next configuration in my project:
-keep class com.squareup.** { *; }
-keep interface com.squareup.** { *; }
EDIT: Some useful examples: https://www.guardsquare.com/en/proguard/manual/examples
Upvotes: 0