Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Proguard Obfuscation Enum Issue

I have following Enum class in my Java package

public enum UIType {
    NATIVE,WEB;
}

I have applied following proguard config to keep this enum class

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

-keep public enum android.ui.UIType  {
    public static **[] values();
    public static ** valueOf(java.lang.String);
}

But when I offuscate my jar file,proguard keeps the UIType enum class but removes both NATIVE,WEB values.

In my obfuscated jar my Enum class looks as follows.

public enum UIType {

}

As seen above NATIVE,WEB values are removed by proguard :(.It is causing issue in my application since it is not finding those values.

Can somebody please guide me here what I am doing wrong.

Thanks

like image 283
Vipul Avatar asked Nov 26 '13 09:11

Vipul


People also ask

How does ProGuard obfuscation work?

In the obfuscation step, ProGuard renames classes and class members that are not entry points. In this entire process, keeping the entry points ensures that they can still be accessed by their original names. The preverification step is the only step that doesn't have to know the entry points.

What is ProGuard jar?

ProGuard is a free shrinker, optimizer, obfuscator, and preverifier for Java bytecode: It detects and removes unused classes, fields, methods, and attributes. It optimizes bytecode and removes unused instructions. It renames the remaining classes, fields, and methods using short meaningless names.


1 Answers

As I understand, you ask it to keep the methods values() and valueOf(), but not the values themselves.

Try

-keep public class com.ggg.xxx.Yyy { *; }
like image 152
18446744073709551615 Avatar answered Sep 21 '22 16:09

18446744073709551615