Arkweb app debug

From openharmonyinsight/openharmony-skills · View interactive version

Arkweb app debug is an AI agent skill from the GitHub repository openharmonyinsight/openharmony-skills. Debug HarmonyOS ArkWeb applications using Chrome DevTools Protocol. Use when Claude needs to: (1) Start ArkWeb debugging sessions, (2) Connect Chrome DevTools to HarmonyOS apps via hdc, (3) Inspect webview elements, console, and network, (4) Test ArkWeb applications with Chrome DevTools MCP, (5) Tro

How to use this skill

Skill file

ArkWeb App Debug

When to Use This Skill

Use this skill when the user needs to debug HarmonyOS ArkWeb (webview) applications:

Quick Start

Start an ArkWeb debugging session:

# Using the debug script (auto-configures environment)
$SKILL_DIR/scripts/start-debug.sh

# Or with explicit package name
$SKILL_DIR/scripts/start-debug.sh --package com.example.app

Bundled Resources

This skill includes debugging scripts in scripts/:

| Script | Purpose |

|--------|---------|

| start-debug.sh | Start debugging session (macOS/Linux, auto-configures environment) |

| start-debug.py | Start debugging session (cross-platform Python) |

| start-debug.bat | Start debugging session (Windows, auto-configures environment) |

All scripts automatically:

For detailed documentation, see references/.

Common Workflows

Start Debugging Session

# Run the debug script from your HarmonyOS project directory
cd /path/to/harmonyos/project
$SKILL_DIR/scripts/start-debug.sh

# The script automatically:
# - Detects project configuration (package name, HAP path)
# - Connects to device
# - Creates port forwarding to webview_devtools socket
# - Opens Chrome DevTools

Integration with ohos-app-build-debug

For complete development workflow:

# 1. Build and install app (using ohos-app-build-debug skill)
$OHOS_SKILL_DIR/scripts/build.py
$OHOS_SKILL_DIR/scripts/install.py -f entry/build/default/outputs/default/entry-default-signed.hap
$OHOS_SKILL_DIR/scripts/launch.py

# 2. Start debugging (this skill)
$SKILL_DIR/scripts/start-debug.sh

AI Automated Testing (with MCP)

When Chrome DevTools MCP is configured, Claude can automatically test webview functionality:

User: Please test the login functionality in my webview
Claude: (Automatically uses Chrome DevTools MCP)
  - Opens DevTools connection
  - Navigates to login page
  - Fills out form
  - Submits and verifies results

See references/mcp-guide.md for MCP setup and available tools.

How It Works

Automatic Detection

The debug scripts automatically:

  1. Detect DevEco Studio: Uses ohos-app-build-debug skill to find DevEco Studio and configure hdc
  2. Find Project: Searches upward for HarmonyOS project root (max 5 levels)
  3. Read Configuration: Extracts package name from AppScope/app.json5
  4. Connect Device: Uses hdc to connect to HarmonyOS device
  5. Find Socket: Dynamically locates webview_devtools socket (handles PID changes)
  6. Create Port Forward: Sets up port forwarding from device to localhost:9222
  7. Open DevTools: Launches Chrome/Chromium with DevTools

Critical Timing

Based on real debugging experience:

The scripts handle these timings automatically.

Response Guidelines

When helping users with ArkWeb debugging:

  1. Check Environment First
  1. Use Scripts
  1. Handle Common Issues
  1. Coordinate with ohos-app-build-debug
  1. Show Actual Commands

Application Requirements

ArkWeb applications must enable debugging in aboutToAppear():

import { webview } from '@kit.ArkWeb';

@Entry
@Component
struct Index {
  controller: webview.WebviewController = new webview.WebviewController();

  aboutToAppear() {
    // CRITICAL: Enable debugging BEFORE Web component renders
    webview.WebviewController.setWebDebuggingAccess(true);
  }

  build() {
    Web({ src: this.currentUrl, controller: this.controller })
  }
}

Error Handling

If DevEco Studio/hdc is not detected:

If device is not connected:

If socket is not found:

For detailed troubleshooting, see references/troubleshooting.md.

Prerequisites

Optional: Chrome DevTools MCP for AI automated testing

Download DevEco Studio: https://developer.huawei.com/consumer/cn/doc/harmonyos-guides/ide-download

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.