Proguard keep class names? Proguard keep class names? java java

Proguard keep class names?


Use the -keepnames option in your proguard.cfg

Refer to the manualhttps://www.guardsquare.com/en/proguard/manual/usage#keepoptions:

-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.


This keeps classnames intact:

-keepnames class com.somepackage.* 


Handy tip for everyone who does not want ProGuard to change any class name:

# please KEEP ALL THE NAMES-keepnames class ** { *; }

This way you will get readable stack traces while still throwing out things you don't need. :-)