If I have a Class B
that implements Interface A
and Proguard isn't aware of the existence of that interface, How can I keep the names of the methods that implements interface A's abstract methods?
Please notice that I want to keep the method names, but I do want their content to be obfuscated.
Update: This is what I have (Please notice the comments):
public class MyService extends Service {
// an anonymous class that implements ServiceConnection
private ServiceConnection myConnection = new ServiceConnection()
{
// don't change the following method's name
@Override
public void onServiceConnected(ComponentName className, IBinder service)
{
// I want this section to be obfuscated
}
}
I want a general solution for these kind of cases - I don't want to state interfaces names in the ProGuard configuration.
So your .pro file should look like this -
#Keeping all public class names and keep (prevent obfuscation) of their public and protected methods
-keep public class * {
public protected <methods>;
}
# Keep (prevent obfuscation) all public and protected methods in non-public classes.
# Notice that the non-public class names will still get obfuscated
-keepclassmembers !public class * {
public protected <methods>;
}
# Don't keep the local variables attributes (LocalVariableTable and LocalVariableTypeTable are dropped).
-keepattributes Exceptions,Signature,Deprecated,SourceFile,SourceDir,LineNumberTable,Synthetic,EnclosingMethod,RuntimeVisibleAnnotations,RuntimeInvisibleAnnotations,RuntimeVisibleParameterAnnotations,RuntimeInvisibleParameterAnnotations,AnnotationDefault,InnerClasses,*Annotation*
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With