解决Google Play审核中的WebViewClient.onReceivedSslError问题

Google Play应用市场提交应用审核,出现因WebViewClient.onReceivedSslError问题致使拒绝经过。web

Google Paly给出的详情地址:support.google.com/faqs/answer…bash

 

 

处理起来其实也相对简单,主要是针对用到WebViewClient对象重写onReceivedSslError()方法。app

如:ide

@Override
public void onReceivedSslError(WebView view, final SslErrorHandler handler, SslError error) {
    AlertDialog.Builder builder = new AlertDialog.Builder(view.getContext());
    builder.setMessage("SSL认证失败,是否继续访问?"); builder.setPositiveButton("肯定", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { handler.proceed(); } }); builder.setNegativeButton("取消", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { handler.cancel(); } }); AlertDialog dialog = builder.create(); dialog.show(); // 上报SslError信息到服务端,以便排查具体问题 CornLog.e(view, handler, error); ... } 复制代码

项目主工程经过直接搜索WebViewClient,对应重写onReceivedSslError()方法,相对都很简单,主要问题在,针对项目中直接引入的jar包和经过gradle dependencies引入的外部库,须要统一核查。post

经过gradle dependencies引入的外部库,一般是以aar形式存在,项目构建过程当中,最终都会将aar中的有效部分,如jar文件,拷贝到当前项目构建目录,参与总体构建过程。gradle

因而,构建完成后,能够经过命令直接查找项目目录下的jar文件,将其中的WebViewClient相关类都找到,并逐一排查,对于涉及到的本身的独立jar文件或gradle dependencies引入的外部库,能够自行修改,对于外部第三方(如QQ,微博等相关的登陆分享库等)的库,能够考虑是否须要升级新的版本(新的版本极可能已经解决,由于第三方也会收到一样的问题或有人已经反馈过),或者反馈给第三方等方式解决。ui

使用搜索命令:
find . -name '*.jar' -exec zipgrep -i WebViewClient {} \;
输出结果为:google

...
com/corn/biz/activity/BbsDetailActivity$LoanWebViewClient.class:Binary file (standard input) matches com/corn/biz/activity/BbsDetailActivity.class:Binary file (standard input) matches com/sina/weibo/sdk/web/client/AuthWebViewClient.class:Binary file (standard input) matches com/sina/weibo/sdk/web/client/BaseWebViewClient.class:Binary file (standard input) matches com/sina/weibo/sdk/web/client/DefaultWebViewClient.class:Binary file (standard input) matches com/sina/weibo/sdk/web/client/ShareWebViewClient.class:Binary file (standard input) matches com/sina/weibo/sdk/web/WeiboSdkWebActivity$1.class:Binary file (standard input) matches com/sina/weibo/sdk/web/WeiboSdkWebActivity$2.class:Binary file (standard input) matches com/sina/weibo/sdk/web/WeiboSdkWebActivity.class:Binary file (standard input) matches sdk/meizu/auth/ui/AuthActivity$1.class:Binary file (standard input) matches sdk/meizu/auth/ui/AuthActivity.class:Binary file (standard input) matches com/cmic/sso/sdk/widget/a$1.class:Binary file (standard input) matches com/cmic/sso/sdk/widget/a.class:Binary file (standard input) matches com/tencent/connect/auth/a$a.class:Binary file (standard input) matches com/tencent/connect/auth/a.class:Binary file (standard input) matches com/tencent/open/c$a.class:Binary file (standard input) matches com/tencent/open/c.class:Binary file (standard input) matches com/tencent/open/TDialog$FbWebViewClient.class:Binary file (standard input) matches com/tencent/open/TDialog.class:Binary file (standard input) matches ... 复制代码

逐一排查每项涉及到的外部文件,并确认是否已经处理好onReceivedSslError()方法。spa

做者:HappyCorn 连接:https://juejin.im/post/5cb1416a6fb9a0685727dd92 来源:掘金 著做权归做者全部。商业转载请联系做者得到受权,非商业转载请注明出处。
相关文章
相关标签/搜索