我有一个类JSBridge (一个内部类),它是一个javascript接口:
private class JsBridge implements JsCallback {
/**
* @param handlerName method required
* @param jsonData data passed through from javascript
* @param jsCallback A callback to trigger when handler specified by handlername has finished, could be null
*/
@JavascriptInterface
public void callHandler(final String handlerName, final String jsonData, final String jsCallback) {
Log.d(App.TAG, "Bridge call from JS, received " + handlerName);
}
@JavascriptInterface
public void onPageLoad(final String pageName) {
Log.d(App.TAG, "Bridge call from JS, received onPageLoad - we have the page name " + pageName);
}这是很好的工作,直到我做了一个发行版与保护程序构建。我尝试跟随其他一些这样的答案,并将以下行添加到我的pro卫士文件中,但这并没有帮助。结果是我得到回调的调试版本,没有回调的发布版本。
-keep public class * implements com.mixcloud.player.view.JsCallback
-keepclassmembers class * implements com.mixcloud.player.view.JsCallback {
<methods>;
}
-keep public class * implements com.mixcloud.player.view.JsCallback
-keepattributes *Annotation*
-keepattributes JavascriptInterface
-keep public class com.mixcloud.player.view.JSRefreshWebView
-keep public class com.mixcloud.player.view.JSRefreshWebView$JsBridge
-keep public class * implements com.mixcloud.player.view.JSRefreshWebView$JsBridge
-keepclassmembers class * implements com.mixcloud.player.view.JSRefreshWebView$JsBridge {
<methods>;
}发布于 2013-07-28 13:06:45
如果您的Javascript接口方法使用@JavascriptInterface进行注释,则可以使用
-keepclassmembers class * {
@android.webkit.JavascriptInterface <methods>;
}https://stackoverflow.com/questions/17815932
复制相似问题