Skip to content Skip to sidebar Skip to footer

Proguard Keep Parameter Names For Interface And Abstract Class

I am trying to prevent proguard from obfuscating interface (or abstract class) methods parameters. Lets say I have this interface in my lib : package com.mypackage; public interfac

Solution 1:

Add following ProGuard options to your configuration.

-keepattributes MethodParameters

If your class file hava method parameters metadata (compiled using Java8 -parameters or etc...)`, ProGuard will keep the metadata.

Solution 2:

To keep all interface methods:

-keep interface * {
   <methods>;
}

To keep all public and protected methods, which could be used by reflection:

-keepclassmembernames class * {
    publicprotected <methods>;
}

While I don't understand, why one would want to keep abstract classes, which cannot be instanced anyway, therefore it's pointless to keep & know their names. In theory, one could exclude all that is notabstract with rules which start with -keep !abstract, but that's kind of redundant.

Solution 3:

Your proguard file may lack some -keepattributes, especially a -keepattributes Signature.

Check this example proguard configuration for a library from the proguard documentation to look for ideas.

Post a Comment for "Proguard Keep Parameter Names For Interface And Abstract Class"