I have an issue since android 4.2 with proguard.
Basically I use a JavascriptInterface on a webview like this:
public class MyJavascriptInterface {
public void doSomething() { ... }
}
Now what I do understand is that when proguard obfuscates the code it renames the class name and method name, so it cannot be called from Javascript anymore. That is why I have to add this to the proguard config:
-keepclassmembers class mypackage.MyJavascriptInterface {
public void doSomething();
}
When I set the target sdk to 17 (Android 4.2) I have to add the @JavascriptInterface
annotation to my Javascript interface method for security reasons:
@JavascriptInterface
public class MyJavascriptInterface {
public void doSomething() { ... }
}
Now the problem is that this does not work anymore if proguard is enabled (doSomething is not called as if the class is still renamed in the obfuscation step). If I disable proguard the code works fine.
How can I make this work with target sdk 17?