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?
- An annotation I could add to the method and have proguard take notice of?
- Somehow specify these types of methods referenced from xml?
- I suppose I can add a false reference in the code, but would like to avoid that if I can as I won’t always remember to put it in!
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:
Hope it helps.