How to debug webview remotely?

后端 未结 6 1267
别跟我提以往
别跟我提以往 2021-02-03 22:48

How can I do debug/inspect element of apk webview.
I have tried this but it is helpful only for chrome not for apk.

Please suggest me

6条回答
  •  独厮守ぢ
    2021-02-03 23:29

    Try this:

    1. Enable Developer Options in Device (Settings-->About Phone-->Tap 7 times on build number)
    2. Turn on Developer options and Enable USB Debugging (in Developer Options)
    3. Add this line in your custom Application class or in the Activity where the Web View is loaded

      // if your build is in debug mode, enable inspecting of web views

      if (0 != (getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE)) {
          WebView.setWebContentsDebuggingEnabled(true);
      }
      
    4. Open Chrome and type chrome://inspect/#devices and you should see your device in the Remote Target List

    5. Click on inspect to debug it.

    Happy coding..

提交回复
热议问题