how to enable WebKit's remote debugging/inspector of Android app using WebView?

前端 未结 5 1988
野趣味
野趣味 2020-12-06 05:27

I need to inspect javascript execution (webview widget) in an android application, while debugging; through SDK & usb cable and/or http/websockets; from destop compute

相关标签:
5条回答
  • 2020-12-06 05:56

    Now it is easy with Android 4.4. See https://developers.google.com/chrome-developer-tools/docs/remote-debugging#debugging-webviews

    0 讨论(0)
  • 2020-12-06 05:59

    For android >= 4.4 (kitkat)

    See Remote debugging on Android with Chrome

    For android < 4.4 (Lower versions)

    Use very good open source tool: weinre. See this video for help to use it. If you are familiar with grunt then you can use grunt-weinre

    For quick view:

    1. install weinre using npm
    2. Do the configuration in your gruntfile.
    3. Run the weinre grunt task.
    4. Use this script to inject the weinre target code into your web page.
    1. Open http://localhost:8082 in your browser and you will find devices running above script. You can debug all this devices.

    NOTE: if you want to debug webview/browser in your mobile device then you need to replace localhost with your machine's IP running weinre. And yes, all the devices should be on the same network.

    0 讨论(0)
  • 2020-12-06 06:03

    Pre KitKat jsHyBugger works well ( trial version and annual single user license €29 )

    ( I have no connection to the developers / have purchased a license )

    0 讨论(0)
  • 2020-12-06 06:07

    It cannot be done, because the debugger backend code is not there. The source code you are referencing to is a copy of webkit source in android, but it is not compiled into android release bits.

    0 讨论(0)
  • 2020-12-06 06:12

    You can do remote debugging targeting the Android Browser with the weinre project. Or use Chrome remote debugging with the Chrome for Android browser. As far as I know, you can't target a WebView directly, but targeting the Android Browser should get you close.

    0 讨论(0)
提交回复
热议问题