Re: [android-developers] Android Proguard - how to keep onClick handlers only referenced from XML layouts

2011-06-11 Thread Marcin Orlowski
If I remember correctly, android uses reflection while accessing onClick
handles specified in layout file instead of set via code, so if I am now
wrong, you will pay for that with performance loss (yes, it's most likely
insignificiant for the whole app, but still). I also think that if you want
to use proguard to make your app harder to rev-eng, you shall consider
dropping android:onClick in faviour of setting handlers in code instead of
exluding them from proguard

Regards,
Marcin Orlowski

*Tray Agenda http://bit.ly/trayagenda* - keep you daily schedule handy...
*Date In Tray* http://bit.ly/dateintraypro - current date at glance...
WebnetMobile on *Facebook http://webnetmobile.com/fb/* and
*Twitterhttp://webnetmobile.com/twitter/
*

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Android Proguard - how to keep onClick handlers only referenced from XML layouts

2011-06-09 Thread andrew
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 reference to this method in my own code (but maybe
somewhere in the auto-generated stuff by Android build?).

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 rework 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?
Can you specify a wildcard for the method name and I can adopt some
convention like onClick*?

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.

I know I can keep specific ones with something like:

-keepclasseswithmembers class * {
   public void onSearchClicked(android.view.View );
}

but in some Activity I have a lof of these, all with different names,
and a lot across the entire application. Using the above method would
mean any change to my code would require a change to my proguard
configI'm looking for a more generic and robust way.

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en