On Sun, Nov 7, 2010 at 10:41 PM, Stephen Jungels <[email protected]> wrote: > I've recently started using the WebView Android / Javascript interface > in my projects (and I think it's pretty cool; article here: > http://developer.android.com/resources/articles/using-webviews.html). > > The problem is that when obfuscation is turned on, the callbacks from > Javascript to my Android code no longer complete, because the language > binding is unaware of the renaming performed by Proguard. > > I can fix this on a case-by case basis; for example in the very simple > code I am using now, the following additional Proguard rules are > enough: > > ----------------------- > -keep public class com.trans_code.android.JsCallback > -keepclassmembers class * { > public void doneClicked(); > } > ---------------------- > > However the second rule seems too broad, and both rules are unique to > each project that uses the Javascript callback. > > Any guidance on how a better rule can be written that catches every > use of Android - Javascript bindings, and nothing else? > > Thanks, > > SJ >
Stephen, I am not sure, whether you would be more selective with not obfuscating some classes, but you could do the following: - define a placeholder interface called say NonObfuscateable (I know it sounds dreadful, but you get the gist) - make all classes that you want to keep implement this interface - tell Proguard to keep the classes that implemented your interface Daniel -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

