I have a custom Webview in my android project as shown below:
public class MyWebView extends WebView {
    public MyWebView(Context context) {
        super(context);
    }
   public class JsObject {
        @JavascriptInterface
        public void show() {
            //...
        }
        @JavascriptInterface
        public void hide() {
            //....
        }
}
that includes a JavascriptInterface which I use to communicate from the JavaScript side to the Android side. 
In the AndroidManifest I had the following
<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="16" />
In the project I used proguard which declared:
-keepattributes JavascriptInterface
-keepclassmembers class * {
    @android.webkit.JavascriptInterface <methods>;
}
and everything was working fine.
However when i changed my AndroidManifest to android:targetSdkVersion=18 or 19 and test on devices with 18 and above, proguard seems to somehow mess the JavaScript methods which are not accessible anymore. 
If I put back to 16 or anything less than 17 everything works fine. Additionally this happens only with proguard. If I don't use proguard everything works fine even with android:targetSdkVersion=18 or 19. Can anyone help to make it work when targeting in the manifest Android > 17?
I copy my answer from this topic for you: https://stackoverflow.com/a/19994873/1735499
And, if you are using Proguard, remember to add this
-keepclassmembers class * {
    @android.webkit.JavascriptInterface <methods>;
}
-keepattributes JavascriptInterface
-keep public class com.mypackage.MyClass$MyJavaScriptInterface
-keep public class * implements com.mypackage.MyClass$MyJavaScriptInterface
-keepclassmembers class com.mypackage.MyClass$MyJavaScriptInterface { 
    <methods>; 
}
If it's still not OK, add this
-keepattributes *Annotation*
Note: your MyJavaScriptInterface must be Public class
Ref#: Android Proguard Javascript Interface Fail
Br,
Frank
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