Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android - how to keep enum from proguard

In my proguard, I have the following to keep public enums from being obfuscated.

-keepclassmembers enum * {
    public static **[] values();
    public static ** valueOf(java.lang.String);
}

My question is, does this also keep the public enum Currency in a class like this?

public class Foo {
    public enum **Currency** {PENNY, NICKLE, DIME, QUARTER};

    ...
}

If not, what do I have to add separately?

Adding the following doesn't seem to help.

-keepattributes InnerClasses

Any advice? Thanks

like image 295
user2062024 Avatar asked Oct 02 '13 23:10

user2062024


2 Answers

If you want to safe enum names and all fields, methods for it:

-keep enum * { *; }
like image 173
Максим Петлюк Avatar answered Sep 19 '22 14:09

Максим Петлюк


You could try

-keep public enum com.stuff.TheEnclosingClass$** {
    **[] $VALUES;
    public *;
}

As shown on this answer Proguard won't keep a class member's enums

Just don't forget to put

-keepattributes InnerClasses
like image 40
Gabriel Falcone Avatar answered Sep 19 '22 14:09

Gabriel Falcone