hdc command guide: connect, install apps and debug OpenHarmony devices
Short answer: hdc (OpenHarmony Device Connector) is the command-line tool for connecting to and debugging OpenHarmony and HarmonyOS devices or emulators. It does what adb does on Android: list devices, install apps, move files, open a shell and read logs.
What is hdc?
hdc has three parts:
- Client: runs on your computer and executes the commands you type in a terminal or from an IDE.
- Server: a background process on your computer that manages communication between the client and the device, including connection multiplexing and data transfer.
- Daemon: runs on the device and handles requests from the client.
Where do I get hdc?
hdc is packaged in the SDK. DevEco Studio includes it in the SDK’s toolchains directory (for example .../sdk/default/openharmony/toolchains). Add that directory to your PATH to run hdc from any terminal. The source code is in the developtools_hdc repository.
Check that it works:
hdc -v
What are the most useful hdc commands?
Devices
hdc list targets # list connected devices
hdc list targets -v # list with details (connection type, state)
Install and remove apps
hdc install path/to/app.hap # install a package
hdc uninstall com.example.app # remove an app by bundle name
Transfer files
hdc file send <local-path> <device-path> # computer -> device
hdc file recv <device-path> <local-path> # device -> computer
Shell and app management
hdc shell # interactive shell on the device
hdc shell bm dump -a # list all installed bundles
hdc shell bm dump -n <bundle-name> # details of one bundle
hdc shell aa start -a <ability> -b <bundle> # start an ability
hdc shell aa force-stop <bundle> # force-stop an app
Logs
hdc hilog # stream device logs
Port forwarding
hdc fport tcp:<local-port> tcp:<device-port> # forward a computer port to the device
hdc fport ls # list forward rules
hdc rport tcp:<device-port> tcp:<local-port> # reverse forwarding (device -> computer)
Server control
hdc kill # stop the hdc server
hdc start -r # restart the server
Why does hdc not show my device?
- Make sure developer mode and USB debugging are enabled on the device, and use a data-capable USB cable.
- Run
hdc list targets. An empty result means that no device is connected or authorized. - Restart the server with
hdc killand thenhdc start -r. - Check that only one version of hdc is on your
PATH, because several SDKs installed on one machine can cause version conflicts. - Reconnect the device and run
hdc list targetsagain.
Next steps
- Your first ArkTS app
- How to install DevEco Studio
- Official hdc documentation: HUAWEI Developers
Frequently asked questions
What does hdc stand for?
hdc stands for OpenHarmony Device Connector. It is a command-line tool to connect to, and debug, OpenHarmony devices or emulators from a development computer.
What is the equivalent of adb for OpenHarmony?
hdc plays the same role as Android's adb: it lists devices, installs and uninstalls apps, transfers files, opens a shell and shows logs.
How do I install a HAP file with hdc?
Run hdc install followed by the path to the .hap file. To remove an app, run hdc uninstall followed by the bundle name.
How do I restart the hdc server?
Run hdc kill to stop the server, then hdc start -r to restart it. This often fixes devices that do not show up.