目录

Running Your App on a Local Real Device

Install and run your HarmonyOS app/atomic service on a local real device in either USB or wireless mode.

Wearables (excluding lite wearables) support only wireless debugging.

Prerequisites

In USB Mode

  1. Use a USB cable to connect the real device to the computer.
  2. Choose Settings > System > Developer options and enable USB debugging (this option is available only when the device is connected through a USB cable).
  3. When a USB debugging authorization prompt appears on the real device, click OK.

  4. On the menu bar, choose Run > Run 'module name' or click , or press Shift+F10 (Control+R on macOS).

  5. DevEco Studio will start to build and install the HAP on the device. The device will automatically run your app/atomic service once it is installed.

[h2]Troubleshooting with the Device Connection Assistant

Since DevEco Studio 5.1.1 Beta1, if DevEco Studio cannot detect the device after it is connected, the message "No Devices" is displayed. You can use the device connection assistant for troubleshooting. Click the device drop-down menu and select Troubleshoot Device Connections to enable it. This initiates a three-step diagnostic process. Click Next after completing each step.

  1. Connect your device via USB. Click Rescan Devices to refresh the connected device list. Ensure your target device appears in the results.
  2. Enable USB debugging. Verify the OS version of your device. Enable Developer options and USB debugging on your device.
  3. Restart the hdc service. If DevEco Studio still cannot identify the device, click Restart hdc Service. This forces hdc to re-detect connected devices. If issues persist, see What should I do if the device cannot be detected after being connected? or What should I do if a device cannot be identified by hdc?.

In Wireless Mode

  1. Connect the real device and the PC to the same WLAN.
  2. Choose Settings > System > Developer options and enable Wireless debugging or Debug via WLAN (for wearables) and obtain the IP address and port number of the device.

  3. Connect the device in either of the following ways:

    • Using DevEco Studio
      • For 6.1.1 Release (6.1.1.300) or later, choose Tools > IP Connection via the menu bar, or click IP Connection in the device drop-down list. Enter the IP address and port number of the device in the format of "IP:port," and click Connect to connect to the device. After the connection is successful, the device is displayed in the list. By default, the screen is always on.

        After screen always-on is enabled, DevEco Studio will continuously send screen-on instructions to the device to keep the screen on. Even if the device is manually locked, the screen will automatically turn back on. This is the normal behavior of DevEco Studio sending screen-on instructions to keep the screen on.

        To disable the screen always-on mode, use either of the following methods:

        • Method 1: Click Disable Screen Always-On in the IP Connection panel.
        • Method 2: Disconnect the device.

        After disabling, DevEco Studio will stop sending screen-on instructions, and the device can enter the sleep mode normally.

      • For versions earlier than 6.1.1 Release (6.1.1.300), choose Tools > IP Connection via the menu bar, enter the IP address and port number of the device to be connected, and click . After the connection is successful, the device status is online.

    • Using the hdc tool (see hdc)
      hdc tconn device IP address:port number

  4. On the menu bar, choose Run > Run 'module name' or click , or press Shift+F10 (Control+R on macOS).

  5. DevEco Studio will start to build and install the HAP on the device. The device will automatically run your app/atomic service once it is installed.