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?