webview js调用android 的函数异常问题

微信支付需要通过webview点击来调用android的微信支付,在debug环境调通,上线到正式环境却有问题,点击按钮无反应,通过多次尝试发现debug版没有问题,打包签名正式版就是不行,于是想到混淆的问题,一看果然是:

If your project uses WebView with JS, uncomment the following

and specify the fully qualified class name to the JavaScript interface

class:

从proguard产生的mapping.txt也可以找到这个被背改名了,所以当js调用它的时候就找不到了:
com.xxxx.WebActivity$JsObject -> com.xxxx.eg:

在proguard-project.txt添加上这几句就可以了
-keepclassmembers class com.xxxx.e.WebActivity$JsObject {
public *;
}

-keepattributes Annotation
-keepattributes JavascriptInterface

发布了7 篇原创文章 · 获赞 1 · 访问量 1189

猜你喜欢

转载自blog.csdn.net/m0_37052189/article/details/89097935