How to keep private Inner Class in ProGuard. I am already using($ for inner class) below code in my proguard.cfg but its not working.
-keep public class com.xxx.droid.activity.LoginActivity$JsInterface
In real use cases, you can let ProGuard do at least some of it’s work. Even if your variables are accessed by reflection, you could remove and rename unused classes, for example. So let’s look through the more specific -keep variants. This protects only the members of the class from shrinking and obfuscation.
This is the most permissive keep directive; it lets ProGuard do almost all of its work. Unused classes are removed, the remaining classes are renamed, unused members of those classes are removed, but then the remaining members keep their original names. This one doesn’t get a table, because it’s the same as -keep.
By default, ProGuard obfuscates the code: it assigns new short random names to classes and class members. It removes internal attributes that are only useful for debugging, such as source files names, variable names, and line numbers. Specifies to print the mapping from old names to new names for classes and class members that have been renamed.
If you don’t specify a keep directive of any kind, then ProGuard is going to do it’s normal thing — it’s going to both shrink (i.e. remove unused code) and obfuscate (i.e. rename things) both classes and class members. See, this is why I said you should almost never use -keep. -keep disables all of ProGuard’s goodness.
This should work:
-keep public class com.xxx.droid.activity.LoginActivity$* {
*;
}
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