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() {
which includes the JavascriptInterface , which I use to communicate on the JavaScript side on the Android side.
In AndroidManifest, I had the following
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="16" />
In the project, I used proguard, which stated:
-keepattributes JavascriptInterface -keepclassmembers class * { @android.webkit.JavascriptInterface <methods>; }
and everything is working fine.
However, when I changed my AndroidManifest to android:targetSdkVersion=18 or 19 and tested on devices with 18 and above, proguard seems to somehow mess up the JavaScript methods that are no longer available.
If I go back to 16 or anything less than 17, everything will be fine. In addition, this only happens with proguard. If I don't use proguard, everything works fine even with android:targetSdkVersion=18 or 19. Can someone help make it work when targeting in an Android manifest of> 17?
source share