2

Here is my Entity class:

class Entity{
    private String id;
    Object content;
    private Type type;
    public enum Type{type1, type2, type3}
}

Depending on type field I pass respective the class to

gson.fromJson(json, <type1/2/3 class, depending on field type>);

But I am using proguard, and this obfuscate the type value, so I am not able to determine which class to use.

I tried to keep type field but its not keeping. Here is my code:

-keepclassmembers enum * { *; }
-keepclassmembers class com.mypkg.Entity {
    private java.lang.String id;
    private com.mypkg.Entity.Type type;
 }

I see that id is being kept, but not the type field.

Please help.

Gabriel Ilharco
  • 1,649
  • 1
  • 21
  • 34
Saksham
  • 304
  • 4
  • 7

2 Answers2

1

This thread may help.

-keep public enum com.mypkg.Entity$** {
    **[] $VALUES;
    public *;
}
Community
  • 1
  • 1
hibob
  • 746
  • 7
  • 17
1

I faced the same issue using Kotlin. Try to use @Keep annotation

Example:

enum class Color {
    @Keep RED,
    @Keep GREEN,
    @Keep BLUE
}
whý
  • 162
  • 8