【OpenHarmony】First Development Guide

prerequisite preparation

  1. Software preparation: download and install mobaXterm, devEco Studio, Vscode
  2. Register an account and adapt to ssh, the process is as follows
    insert image description here

devEco StudioEngineering development

  1. Installation and download of devEco Studio: Link
    Note: When you open the software after installation, you will be asked to install the sdk. You can pay attention to the installation path of the sdk; when you download the sdk, you will also download hdc. You can copy hdc with the command hdc_std, and then Its directory is configured in the environment variable. For example, my directory is D:\software\hwSdk\openharmony\9\toolchains

  2. The first devEco project created: link

  3. devEco project signature
    Manual configuration: link
    Automatic configuration: Log in to devEco studio with a Huawei account (upper right corner of the software); download the OH version from the sdk; configure automatic signature in the project structure;

NAPI interface

NAPI development example: available for learning
https://www.51cto.com/article/705787.html
https://www.51cto.com/article/693626.html

hdc debug command

hdc common commands: link

hdc kill   //杀死hdc
hdc start   //重启hdc
hdc list targets  //查看连接的设备
hdc shell bm get --udid    //查看UDID
hdc file recv /system/lib/module/libfont.z.so D:\OH\push\raw  传输文件到本地
hdc shell mount -o rw,remount /    解决send失败,文件目录只读问题
hdc file send D:\OH\push\libfont.z.so /system/lib/module/   本地文件传输到设备上
hdc shell reboot  重启设备
hdc  hilog > xxx/log.txt  收集日志
hdc shell rm -rf /data/log/hilog/    清除日志目录
hdc file recv /data/log/hilog D:\OH\push\hilog   导出日志

[Question 1] hdc cannot find the device suddenly, "Connect server failed"
[Solution]: Delete the HDC_SERVER_PORT port in the environment variable directly; if there is hdcExternXXXX.exe in the device manager, close devEco Studio; the terminal command line hdc kill, Restart hdc start; reopen a terminal command window hdc list targets shows ok
Other references: https://www.hmxthome.com/develop/371.html

[Question 2] There is no log information in the /data/log/hilog directory
[Solution] Logs need to be moved to disk, and the execution is as follows

C:\Users\f00574385>hdc shell
# cd
# cd /data/log/hilog
# ls
# hilog -Q pidoff
Set flow control by process to disabled, result: Success [CODE: 0]
# hilog -Q domainoff
Set flow control by domain to disabled, result: Success [CODE: 0]
# hilog -G 100M   //设置日志缓存
Set log type app buffer size to 100.0M successfully
Set log type init buffer size to 100.0M successfully
Set log type core buffer size to 100.0M successfully
# hilog -p off   //打开c++隐藏日志
Set hilog privacy format off successfully
# hilog -b D    //设置日志打印最低等级为DEBUG
Set global log level to D successfully
# hilog -w start -t kmsg //日志落盘,保存路径为/data/log/hilog/
Persist task [jobid:2] start successfully

# hdc shell hilog -b X  关闭日志

OH code download and compile

1. Code download

repo init -u [email protected]:openharmony/manifest.git -b master --no-repo-verify
repo sync -c
repo forall -c 'git lfs pull'

2. Compile

Full compilation: bash build/prebuilts_download.sh && ./build.sh --product-name rk3568 --ccache
output directory: ./out/rk3568/packages/phone/images
and flash the phone.

Module compilation (arkui): ./build.sh --product-name rk3568 --build-target ace_engine --ccache (other modules: graphic_standard) output
directory: ./out/rk3568/arkui/ace_engine/

3. Flash Tutorial

Summary of OpenHarmony RK3568 development board programming process_maskrom switch to loader mode_Hero_rong's Blog-CSDN Blog

4. Problem record

[Question 1] [Compilation] The compilation fails without modification;
[Solution] It is best to execute it before compiling

rm -rf out build/resources/args/*.json
bash build/prebuilts_download.sh
./build.sh --product-name rk3568 --ccache

[Question 2] [Compilation] The function definition cannot be found
[Reason] After the pure virtual function is defined in the parent class, all derived subclasses need to define its implementation.

[Question 3] [Compilation] ld.lld: error: undefined symbol: xxx
[Reason] ld.lld is an error report related to the library. If you want to adjust a function, you must not only include the header file, but also include the The library is added in the compiled script, otherwise it is easy to find this kind of function can not be found

   deps=  [ "//foundation/graphic/graphic_2d/rosen/modules/texgine:libtexgine" ]
   include_dirs = ["//foundation/graphic/graphic_2d/rosen/modules/texgine/src/" ]

[Problem] [Development] When obtaining system fonts, the OH code is printed in Chinese, and the application layer prints garbled characters [
Solution] The application layer uses utf-8 encoding, and the underlying OH code is gdk encoding

[Problem] [Prompt pr] When I updated my commit, I brought other people's modifications.
[Reason] git pulled the personal warehouse, and when the personal warehouse was returned to the OH public warehouse, the code of the personal warehouse lagged behind, which led to the rollback of other people's modifications.

git branch -vv  //查看当前本地分支挂载的远程分支是哪个?
git branch --set-upstream-to=tmp/master    // 确保本地分支挂载的远程分支改为自己fork的个人仓tmp
git add ./
git commit -sm "xxx"  //或者  git commit --amend
git pull --rebase  origin master 将公共仓的代码更新至本地(因为公共仓有别人已合的commit)
//如果有冲突,就解决冲突
git push tmp HEAD:master -f //推送到自己的远程仓,此时会自动更新pr,需要-f  因为本地与个人仓有差异,个人仓滞后。

linux command

Remember the commands I keep forgetting:

du -sh  查看该目录占用内存
zip -r xxx.zip xxx/   压缩该目录
pwd  查看绝对路径

Other problem records

[Question 1] [Computer] If you use a kvm thief card, there is no problem with direct usb
[Solution] Just go to the computer settings and re-update the driver;

Guess you like

Origin blog.csdn.net/cocoduco/article/details/130995421