项目作者: mpotthoff

项目描述 :
Debug your JavaScript code running in WebViews on any Android device from VS Code.
高级语言: TypeScript
项目地址: git://github.com/mpotthoff/vscode-android-webview-debug.git
创建时间: 2018-08-28T18:15:08Z
项目社区:https://github.com/mpotthoff/vscode-android-webview-debug

开源协议:GNU Lesser General Public License v3.0

下载





logo


VS Code - Android WebView Debugging




Debug your JavaScript code running in WebViews on any Android device from VS Code.


GitHub Release
Visual Studio Marketplace Release
GitHub Actions Build Status
License

A VS Code extension to debug your JavaScript code in the Google Chrome browser or other WebView targets on Android devices, that support the Chrome DevTools Protocol.

Demo

Requirements

vscode-js-debug

This extension uses the vscode-js-debug extension under the hood.

Using the debugger

When your launch config is set up, you can debug your project. Pick a launch config from the dropdown on the Debug pane in Code. Press the play button or F5 to start.

Configuration

Right now the extension only supports attaching to an already running Google Chrome or WebView instance. This can be configured in the .vscode/launch.json file in the root directory of your project.

In case you want to use the old Debugger for Chrome extension you can set debug.javascript.usePreview to false.

All configuration options of the pwa-chrome: attach configuration of the vscode-js-debug extension are supported.

You can optionally specify a port to use for the debugging connection or let the extension automatically choose an unsued one.

It is possible to specify the device and/or the application to attach to. If multiple possible instances are found the extension will ask you to choose one.

An example launch.json file:

  1. {
  2. "version": "0.2.0",
  3. "configurations": [
  4. {
  5. "type": "android-webview",
  6. "request": "attach",
  7. "name": "Attach to Android WebView",
  8. "application": "com.android.chrome",
  9. "webRoot": "${workspaceFolder}",
  10. "urlFilter": "http://example.com/*"
  11. }
  12. ]
  13. }

All contributed configuration fields

  • device: The serial of the device to use. It can be found using adb devices.
  • application: The package name of the application to connect to. For example com.android.chrome.
  • connectTimeout: The time the extension will wait for the webview to be ready in milliseconds.

Extension Settings

This extension contributes the following settings:

  • android-webview-debug.adbPath: Specifies the path to the ADB executable.
  • android-webview-debug.adbArgs: Specifies extra arguments for the ADB executable. For example ["-H", "1.2.3.4"]

Troubleshooting

Failed to locate ADB executable.

The ADB executable was not found. Usually it should be on the PATH environment variable. You can also specify it manually using the android-webview-debug.adbPath configuration parameter.

No WebViews found

Ensure that the device is connected and that the Android application is a debug build or WebView debugging is enabled. You can always find the available WebViews by visiting chrome://inspect/#devices in Google Chrome.

No devices found

Ensure that USB Debugging is enabled on your Android device and that ADB can find it. You can find a list of connected devices using the command adb devices.