In my Android app I ofter don't create a View's on-click handler in code, but rely on the ability to specify it in the XML layout file, like this:
<Button
....
android:onClick="onSearchClicked"
...../>
And then have the method in the Activity like this:
public void onSearchClicked( View v ) {
........}
Meaning there is no obvious reference to this method in my own code.
When running Proguard for a production release it seems to remove this method and the on-click fails.
What can I add to my proguard config file to avoid this that won't oblige me to rename all these methods?
I have looked through the proguard examples for Android and can't see anything for this particular need.
This seems to be the best answer, as it is 100% robust to naming of such methods:
# This will avoid all the onClick listeners referenced from XML Layouts from being removed
-keepclassmembers class * extends android.app.Activity {
public void *(android.view.View);
}
Hope it helps.
-keepclasseswithmembers class * {
public void onSearchClicked(android.view.View );
}
but double check it from proguard doc : http://proguard.sourceforge.net/index.html#/manual/refcard.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With