OpenHarmony 4.0 Release 编译异常处理

一、环境配置

编译环境:Ubuntu 20.04
OpenHarmony 软件版本:4.0 Release
设备平台:rk3568

二、下拉代码

参考官网步骤:
OpenHarmony 4.0 Release 源码获取

repo init -u https://gitee.com/openharmony/manifest -b OpenHarmony-4.0-Release --no-repo-verify
repo sync -c
repo forall -c 'git lfs pull'

三、编译代码

参考官网构建步骤:
v4.0 Release 编译构建

 bash build/prebuilts_download.sh
./build.sh --product-name rk3568 --ccache

如果上述步骤一切顺利,编译通过,build log如下:

...
Please modify according to README.md
[OHOS INFO] rk3568 build success
[OHOS INFO] Cost time:  0:58:44
=====build  successful=====
2023-11-08 14:48:55
++++++++++++++++++++++++++++++++++++++++

四、下拉及编译中遇到的问题

4.1、repo: error: unable to resolve “fork_flow”

下拉代码执行报错

$ repo init -u https://gitee.com/openharmony/manifest -b master --no-repo-verify
Downloading Repo source from https://mirrors.tuna.tsinghua.edu.cn/git/git-repo/
remote: Enumerating objects: 4885, done.
remote: Counting objects: 100% (4885/4885), done.
remote: Compressing objects: 100% (2425/2425), done.
remote: Total 8626 (delta 4312), reused 2460 (delta 2460), pack-reused 3741
Receiving objects: 100% (8626/8626), 4.16 MiB | 9.25 MiB/s, done.
Resolving deltas: 100% (5577/5577), done.
repo: warning: verification of repo code has been disabled;
repo will not be able to verify the integrity of itself.

repo: error: unable to resolve "fork_flow"
fatal: cloning the git-repo repository failed, will remove '.repo/repo'

unable to resolve “fork_flow”" 表明repo工具无法解析名为 “fork_flow”,实际上fork_flow是repo仓库的一个分支
repo源码:开源中国/repo
解决方案:

$ which repo	#查看repo安装路径
/home/xxx/bin/repo

$ sudo vim /home/xxx/bin/repo 
#REPO_REV = 'fork_flow' 改为 REPO_REV = 'fork_flow' 

4.2 ERROR: HTTP error 404 while getting http://repo.huaweicloud.com/repository/pypi/…

执行bash build/prebuilts_download.sh后出现如下报错

$ bash build/prebuilts_download.sh 
Defaulting to user installation because normal site-packages is not writeable
Looking in indexes: http://repo.huaweicloud.com/repository/pypi/simple
Collecting rich
  Obtaining dependency information for rich from http://repo.huaweicloud.com/repository/pypi/packages/8d/5f/21a93b2ec205f4b79853ff6e838e3c99064d5dbe85ec6b05967506f14af0/rich-13.5.2-py3-none-any.whl.metadata
  ERROR: HTTP error 404 while getting http://repo.huaweicloud.com/repository/pypi/packages/8d/5f/21a93b2ec205f4b79853ff6e838e3c99064d5dbe85ec6b05967506f14af0/rich-13.5.2-py3-none-any.whl.metadata
ERROR: 404 Client Error: Not Found for url: http://repo.huaweicloud.com/repository/pypi/packages/8d/5f/21a93b2ec205f4b79853ff6e838e3c99064d5dbe85ec6b05967506f14af0/rich-13.5.2-py3-none-any.whl.metadata
prebuilts_download start
...

无效url:http://repo.huaweicloud.com/repository/pypi/packages/…
解决方案:
使用其他国内(清华)镜像源替换华为的pypi源,修改如下:

# build/prebuilts_download.sh
-    pypi_url='http://repo.huaweicloud.com/repository/pypi/simple'
+    pypi_url='https://pypi.tuna.tsinghua.edu.cn/simple'

4.3 一直卡在start npm install, please wait.

执行bash build/prebuilts_download.sh后一直卡在start npm install, please wait.
分析prebuilts_download.sh代码发现是npm源的问题,于是替换npm默认url
解决方案:
使用国内(淘宝)镜像源替换华为npm源,修改如下:

# build/prebuilts_download.py
-    parser.add_argument('--npm-registry', default='https://repo.huaweicloud.com/repository/npm/',
+    parser.add_argument('--npm-registry', default='https://registry.npm.taobao.org/',

你可能感兴趣的:(OpenHarmony,鸿蒙,npm)