介绍:hdc(OpenHarmony Device Connector)是为开发人员提供的用于设备连接调试的命令行工具,该工具需支持部署在 Windows/Linux/Mac 等系统上与 OpenHarmony 设备(或模拟器)进行连接调试通信。简单来讲,hdc 是 OpenHarmony 提供的用于开发人员调试硬件、应用的命令行工具,用在电脑与开发板之间的交互。

hdc适用于 OpenHarmony 应用、硬件开发及测试人员,是每个开发人员的必备、入门工具。


下载sdk获取(建议)

通过访问本社区网站下载[dailybuilds](http://ci.openharmony.cn/workbench/cicd/dailybuild/dailylist) 或正式发布的sdk压缩包,从中根据自己平台到相应的目录toolchain下解压提取。

常用命令,以hdc_std为例

1、hdc是否安装成功

命令:hdc_std shell (能识别即成功)

2、关机

命令:hdc_std shell reboot shutdown

3、、重新启动系统

命令:hdc_std shell reboot

4、安装应用:

命令:hdc_std install 应用包所在路径

举例:hdc_std install D:\liukch\downloads\hengping\browser.hap

5、卸载应用

命令:hdc_std uninstall [BundleName]

举例:hdc_std uninstall com.archermind.web

6、查BundleName和AbilityName名称

命令:hdc_std shell wukong appinfo

7、上传文件到pad

命令:hdc_std file send 文件路径(文件位置) 文件上传pad的路径

举例:hdc_std file send D:\wy\downloads\img\8.jpg /storage/media/100/local/files/Pictures

8、从pad下载文件到电脑

命令:hdc_std file recv 文件路径(文件位置) 文件下载到电脑的路径

举例:hdc_std file recv storage/media/100/local/files/Pictures/Screenshots D:\

9、查看日志

命令:hdc_std hilog

10、抓取log并保存

命令:hdc_std hilog >log.log

举例:hdc_std hilog > D:\log.txt

11、查询连接设备

命令:hdc_std list targets

12、获取设备udid

命令:hdc_std shell bm get -u

13、查看应用配置信息

命令:hdc_std shell bm dump -n [BundleName]

举例:hdc_std shell bm dump -n com.archermind.web

14、清除应用缓存

命令:hdc_std shell bm clean -n [BundleName] -c

举例:hdc_std shell bm clean -n com.archermind.web -c

15、清除应用数据

命令:hdc_std shell bm clean -n [BundleName] -d

举例:hdc_std shell bm clean -n com.archermind.web -d

16、启动指定应用

命令:hdc shell aa start -a EntryAbility -b 包名

举例:  hdc_std shell aa start -a EntryAbility -b com.archermind.web

17、强制退出应用

命令:hdc_std shell aa force-stop [BundleName]

举例:hdc_std shell aa force-stop com.superred.reminder

18、查看当前任务栈的ability信息(后台启动的应用)

命令:hdc_std shell aa dump -l

19、截图

命令:

hdc_std shell snapshot_display -f /data/screenshot.png

hdc_std shell file recv /data/screenshot.png D:


常见问题

  • hdc list targets 查找不到设备

1)检查设备是否连接正常;

2)host端设备管理器设备信息是否正常;

3)两端工具版本是否一致;

4)设备端hdcd是否启动正常;

如果同样版本windows下正常,linux下无设备

可能是usb操作权限问题:sudo chmod -R 777 /dev/bus/usb/

如果仍然无法解决问题,请尝试下面两种方法进行恢复

1)执行命令hdc kill来重启pc侧hdc服务;

2)重启端侧设备:hdc start -r

  • 拷贝文件到开发板失败

    hdc file send d:\ohtest.hap /system/

    [Fail]Error opening file: read-only file system, path:/system//ohtest.hap

    1. 重新挂在目标目录

    hdc shell mount -o rw,remount

    1. 可能目标目录只读,更换其他可读写目录尝试一下

    hdc file send d:\ohtest.hap /data/

    FileTransfer finish, Size:xxx time:86ms rate:xxxkB/s

Logo

讨论HarmonyOS开发技术,专注于API与组件、DevEco Studio、测试、元服务和应用上架分发等。

更多推荐