Search code examples
javaandroidproguardobfuscationandroid-proguard

Proguard keep only class name and all members and methods inside the class


Documentation is not clear enough to explain this.

-keepnames class_specification

Short for -keep,allowshrinking class_specification

Specifies classes and class members whose names are to be preserved, if they aren't removed in the shrinking phase. For example, you may want to keep all class names of classes that implement the Serializable interface, so that the processed code remains compatible with any originally serialized classes. Classes that aren't used at all can still be removed. Only applicable when obfuscating.

Please anyone can explain about keepnames attribute. will this keep only class name or all the members and methods of class. Please provide me a way to keep only class name not all the methods and members of the class.

Sorry for bad english. I thought i explained my problem clearly.


Solution

  • Please go through the documentation; it has everything and little bit of trial and error needed to fully understand. :)

    proguard documentation

    By the way, just to keep the class name add the following line to your progurard file

    -keepnames class your.package.name.ClassName {
    
    }
    

    example:

    -keepnames class com.example.test.domain.Person {
    
    }