解決Google Play審核中的WebViewClient.onReceivedSslError問題


Google Play應用市場提交應用審核,出現因WebViewClient.onReceivedSslError問題導致拒絕通過。

Google Paly給出的詳情地址:support.google.com/faqs/answer…

 

 

處理起來其實也相對簡單,主要是針對用到WebViewClient對象重寫onReceivedSslError()方法。

如:

@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引入的外部庫,需要統一核查。

通過gradle dependencies引入的外部庫,通常是以aar形式存在,項目構建過程中,最終都會將aar中的有效部分,如jar文件,拷貝到當前項目構建目錄,參與整體構建過程。

於是,構建完成后,可以通過命令直接查找項目目錄下的jar文件,將其中的WebViewClient相關類都找到,並逐一排查,對於涉及到的自己的獨立jar文件或gradle dependencies引入的外部庫,可以自行修改,對於外部第三方(如QQ,微博等相關的登錄分享庫等)的庫,可以考慮是否需要升級新的版本(新的版本很可能已經解決,因為第三方也會收到同樣的問題或有人已經反饋過),或者反饋給第三方等方式解決。

使用搜索命令:
find . -name '*.jar' -exec zipgrep -i WebViewClient {} \;
輸出結果為:

...
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()方法。


作者:HappyCorn
鏈接:https://juejin.im/post/5cb1416a6fb9a0685727dd92
來源:掘金
著作權歸作者所有。商業轉載請聯系作者獲得授權,非商業轉載請注明出處。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM