鸿蒙开发环境配置搭建

最近在开发鸿蒙的应用,鸿蒙的系统底层与安卓一样都是linux底座,在linux开发的跨平台应用也可以在鸿蒙也编译,只是鸿蒙调试与编辑文件目前还不是很方便,为了记录大体过程,整理以下:

一、软件编译:

1.下载与安装DevEco Studio工具

2.在windows下使用cmake工程编译命令主要是两步:

powershell 复制代码
step1:
C:\Program` Files\Huawei\DevEco` Studio\sdk\default\openharmony\native\build-tools\cmake\bin\cmake -G "Ninja" -D OHOS_STL=c++_shared -D OHOS_ARCH=arm64-v8a -D OHOS_PLATFORM=OHOS  -DCMAKE_MAKE_PROGRAM=ninja -D CMAKE_TOOLCHAIN_FILE=C:\Program` Files\Huawei\DevEco` Studio\sdk\default\openharmony\native\build\cmake\ohos.toolchain.cmake ..
step2:
C:\Program` Files\Huawei\DevEco` Studio\sdk\default\openharmony\native\build-tools\cmake\bin\cmake --build .

hdc命令使用,感谢csdn网友的提供

https://blog.csdn.net/Androidbye/article/details/147536927

二、连接设备(使用usb线连接设备)

1.hdc list targets (获取设备信息)

2.hdc shell (进入板的命令行终端)

二、连接设备(使用网络连接设备)

1.hdc tmode port 6666 (设置使用网络方式连接设备, hdc tmode usb为使用usb连接方式)

2.hdc tconn 192.168.151.216:6666

3.hdc shell (进入板的命令行终端)

三、同时启用 hdc tcp 和 usb 模式

#进入shell终端

hdc shell

#设置属性 persist.hdc.mode 为all ,同时启用hdc tcp和usb模式

param set persist.hdc.mode all

#设置属性 persist.hdc.port 端口号

param set persist.hdc.port 6666

#设置属性 persist.hdc.mode 为tcp ,启用hdc tcp模式

param set persist.hdc.mode tcp

#设置属性 persist.hdc.mode 为usb ,启用hdc usb模式

param set persist.hdc.mode usb

四、设置静态ip

powershell 复制代码
#本地创建一个新的配置文件
cat > ethernet_interfaces.json <<EOF
{
  "config_ethernet_interfaces":[
    {
      "iface":"eth0",
      "caps":[
      ],
      "ip":"192.168.0.10",
      "gateway":"192.168.0.1",
      "dns":"",
      "netmask":"255.255.255.0",
      "route":"0.0.0.0",
      "routemask":"0.0.0.0"
    }
  ]
}
EOF

#修改system分区为可写并上传配置文件

powershell 复制代码
hdc shell "mount -o rw,remount /"
hdc file send ethernet_interfaces.json /system/etc/communication/netmanager_ext/

#重启生效

hdc shell reboot

#重启后确认生效

hdc shell "ifconfig eth0"

五、文件传输(支持整个目录传输)

1.发送文件 hdc file send .\a.txt /data/local/tmp/

2.接收文件 hdc file recv /data/local/tmp/a.txt ./

六、安装包

1.安装包 hdc install test.hap

2.卸载包 hdc uninstall test.hap

七、增加shell脚本自动启动

1.hdc_std shell mount -o remount,rw /

hdc_std shell mount -o remount,rw /system

hdc_std shell mount -o remount,rw /vendor

2.创建 init 配置文件 (.cfg)

init 配置文件是告诉系统在启动时做什么的蓝图。你需要为你的脚本创建一个专属的 .cfg 文件。

文件名:你可以取一个有意义的名字,比如 my_script.cfg。

文件内容:按照下面的模板进行配置。把文件推到/vendor/etc下面json

powershell 复制代码
{
    "jobs" : [{
        "name" : "boot",
        "cmds" : [
            "start my_service"
        ]
    }],
    "services" : [{
        "name" : "my_service",
        "path" : ["/data/local/my_script.sh"],
        "uid" : "root",
        "gid" : ["root", "shell"],
        "oneshot" : true
    }]
}
相关推荐
贾伟康16 小时前
【口算王|02】HarmonyOS ArkTS 答题提交实战:防止重复提交并推进下一题
harmonyos·arkts·状态管理·arkui·幂等设计
承渊政道17 小时前
Python IDLE鸿蒙PC适配全记录:从Tkinter桌面程序到ArkUI原生开发闭环
开发语言·python·harmonyos·鸿蒙系统·桌面程序
万物智能信息科技18 小时前
电容触摸 FT5406,另一颗芯片、同一条总线—【万物智能之开源鸿蒙OpenHarmony系统实战开发系列教程】
人工智能·华为·开源·harmonyos·鸿蒙
ChinaDragonDreamer18 小时前
HarmonyOS:应用程序包管理模块(获取当前应用信息)
harmonyos·鸿蒙
●VON18 小时前
Flutter 鸿蒙插件适配实战:用 boot_time_plugin 1.0.0 读取启动时间与运行时长
flutter·华为·harmonyos
颜颜yan_19 小时前
Git Cola 鸿蒙 PC 版适配全记录:从 Qt 桌面工具到 ArkTS 原生应用
git·qt·harmonyos
承渊政道20 小时前
Python IDLE鸿蒙PC适配全记录:用 ArkUI 重建编辑、运行、Shell 与基础调试闭环
python·microsoft·harmonyos·鸿蒙系统·pc端
User_芊芊君子20 小时前
RapidSVN 鸿蒙 PC 适配全记录:用 ArkUI 重建工作台,打通本地 SVN 操作闭环
华为·svn·harmonyos
lqj_本人21 小时前
WinMerge 鸿蒙 PC 适配全记录:以 Qt 重建桌面外壳,打通文件与文件夹差异闭环
qt·华为·harmonyos
不羁的木木21 小时前
给鸿蒙 App 增加唤起系统邮件发送能力 —— flutter_email_sender 的鸿蒙使用指南
flutter·华为·harmonyos