Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ProGuard: keep private Inner Class

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
like image 747
Subrat Avatar asked Jun 04 '13 13:06

Subrat


People also ask

Should I use ProGuard for my classes?

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.

What is the most permissive keep in ProGuard?

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.

How does ProGuard obfuscate the code?

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.

What happens if you don’t have a keep directive in ProGuard?

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.


1 Answers

This should work:

-keep public class com.xxx.droid.activity.LoginActivity$* {
        *;
 }
like image 160
Jainendra Avatar answered Oct 07 '22 13:10

Jainendra