How to get proguard to obfuscate enum fields and methods

Viewed 501

Say I have an enum like this:

enum Color { RED,BLUE,GREEN }

After using proguard, and then JADX to de-compile the source code, I noticed that the enums have been only partially obfuscated.

In the de-compiled code, I get something like this:

f.RED

How can I get also get the fields/constants and methods to be obfuscated too?

EDIT!

Don't think this is possible (for good reason), and you should NOT be trying to do this anyway.

Think about what would happen in the case of Color.RED.name() if RED had been obfuscated and you were expecting the String RED.

2 Answers

I put this into my proguard-rules.pro

-ignorewarnings
-dontwarn **CompatHoneycomb
-dontwarn **CompatHoneycombMR2
-dontwarn **CompatCreatorHoneycombMR2
-keepclasseswithmembernames class * {
    native <methods>;
}
-keepclasseswithmember class * {
    native <init>(android.content.Content, android.util.AttributeSet);
}
-keepattributes SourceFile,LineNumberTable
Related