Proguard and reflection in Android
For the on click fix you don't have to list each method name. You can do:
-keepclassmembers class * {
public void *(android.view.View);
}
which find all methods that have a View as parameter.
SOLVED
For others that are having this problem you need to add the following to proguard.cnf
-keep public class * extends com.yoursite.android.yourappname.YourClassName
-keepclassmembers class * extends com.yoursite.android.yourappname.YourClassName{
public <init>(android.content.Context);
}
The first keep tells proguard to not obfuscate class names that extend YourClassName
The second one says to keep the constructor name (<init>
means constructor) un-obfuscated that has a single argument of Context
and extends YourClassName
In addition, for android developers that are using the onClick attribute in you XML layouts file you will also need to add the name of the function in your proguard.cnf file.
-keepclassmembers class * {
public void myClickHandler(android.view.View);
}
This says keep all methods named myClickHandler
with a single argument View
in all classes. You could further constrain this by using the extends keyword like above.
hope this helps.