鸿蒙开发环境配置搭建

最近在开发鸿蒙的应用,鸿蒙的系统底层与安卓一样都是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
    }]
}
相关推荐
YM52e1 天前
鸿蒙ArkTS实战项目 - 门店陈列巡检台:巡检卡片与多列切换实现
学习·华为·harmonyos
lilian2331 天前
Harmony os 技术实战|拼豆制图27:用单字符编码承载 50 张 70×70 图纸
前端·数据库·华为·harmonyos
HwJack201 天前
UIAbility 生命周期全链路:从冷启动到热启动的实战笔记
笔记·华为·harmonyos
梦想不只是梦与想1 天前
鸿蒙 AppGallery Connect:应用创建(二)
harmonyos·appgallery·创建应用
●VON2 天前
芯笺 Markdown:面向 HarmonyOS PC 的本地优先 Markdown 编辑器
华为·编辑器·harmonyos·鸿蒙
世人万千丶2 天前
鸿蒙项目实战 - 社区活动编排板:标签云布局算法与自动换行
学习·算法·华为·harmonyos·鸿蒙
YM52e2 天前
鸿蒙ArkTS项目实战 - 门店陈列巡检台:完整代码与运行效果
学习·华为·harmonyos
贾伟康2 天前
【中国方言题库|06】HarmonyOS ArkTS 闽南语与客家话实战:统一分库页面导航与空状态
harmonyos·arkts·arkui·router·空状态
贾伟康2 天前
【中国方言题库|07】HarmonyOS ArkTS 方言练习实战:推进题目、提交答案并同步统计
harmonyos·arkts·数据持久化·状态管理·arkui
深念Y2 天前
RIO-UL00(EMUI 4.1 / Android 6.0.1 / arm64)开机自启动 sshd
android·linux·华为·安卓·chroot·sshd·emui