Prevent class member name obfuscation by ProGuard

If you dont want your class members to be obfuscated then use SerializedName annotation provided by Gson. For example: public class ClassMultiPoints { @SerializedName(“message”) public String message; @SerializedName(“data”) public List<ClassPoints> data; … } Moreover, make sure you do add proper proguard configuration for Gson library too. For example: ##—————Begin: proguard configuration for Gson ———- # … Read more

How can I force Proguard to keep my .xml resource file?

You shoud add a new file keep.xml under res/raw. <?xml version=”1.0″ encoding=”utf-8″?> <resources xmlns:tools=”http://schemas.android.com/tools” tools:keep=”@layout/l_used*_c,@layout/l_used_a,@layout/l_used_b*” tools:discard=”@layout/unused2″ /> In tools:keep, you list the layouts you want to keep. You can even keep specefic drawables if you use reflection in your code to get your drawable tools:keep=”@drawable/ico_android_home_infosperso” I prefer to add tools:shrinkMode=”strict” so that I make sure … Read more

In proguard, how to preserve a set of classes’ method names?

For native methods: ProGuard manual > Examples > Processing native methods # note that <methods> means any method -keepclasseswithmembernames,includedescriptorclasses class * { native <methods>; } In this case, for callback methods: ProGuard manual > Examples > Processing callback methods -keep class mypackage.MyCallbackClass { void myCallbackMethod(java.lang.String); } Or e.g., if all public methods may be callback … Read more