WebView 调试

  1. 在代码中加入:
    /**
    * 设置 webview 是否可调试
    */
    public void setDebugEnabled(Context context) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
    if (0 != (context.getApplicationInfo().flags &= ApplicationInfo.FLAG_DEBUGGABLE)) {
    webview.setWebContentsDebuggingEnabled(true);
    }
    }
    }
  2. 在Chrome浏览器中打开地址:chrome://inspect/#devices
  3. 将手机连上电脑,即可
  4. 注意:需要用debug包(release包暂时不好使,原因因为时间原因暂时没调研)
原文地址:https://www.cnblogs.com/lianghui66/p/6003909.html