Flutter Love 鸿蒙

前言

大喵Harmony 开始支持 Flutter ,聊聊 Harmony 和 Flutter 之间的因果 - 掘金 (juejin.cn) 提到已经有 针对 OpenHarmony 的 Flutter 版本已经开源。

OpenHarmony-SIG/flutter_flutter (gitee.com)

但是只支持在 linux 上面编译。

而 Windows 上面有 WSL(Windows Subsystem for Linux), 我们可以很方便的获得 linux 环境。

OpenHarmony-SIG/flutter_flutter (gitee.com)OpenHarmony-SIG/flutter_engine (gitee.com) 的文档写的比较简单,很多东西需要 openharmony 官方文档中找到的查找 。坑我都踩过了,大家可以按照我的步骤,避免走冤枉路。

WSL

  • 设置=》控制面板 =》程序 =》启动或关闭 Windows 功能

确保 适用于 Linux 的 Windows 子系统虚拟机平台 开启。

  • 去微软商店中搜索 ubuntu,我安装的是Ubuntu 22.04.2 LTS 版本
  • 安装完毕之后,打开 Ubuntu 22.04.2 LTS ,第一次打开会让你创建账号和密码。

  • 对于习惯图形化的我来说,能少敲命令肯定更愿意少敲。所以打开你的 vscode ,安装插件 WSL 。顺手你可以把 Flutter 插件也安装了。

这样子,通过 vscode 打开 WSL 就这样子的。

我们的项目到时候就都放在 home/zmtzawqlp 下面。

环境

apt 国内源

这个其实没有配置,因为后面也需要代理翻墙,如果你需要设置的话,按照下面操作。

bash 复制代码
# 备份
sudo mv /etc/apt/sources.list /etc/apt/sources.list.bak
# 修改
sudo vim /etc/apt/sources.list

内容可以从下面复制

ubuntu | 镜像站使用帮助 | 清华大学开源软件镜像站 | Tsinghua Open Source Mirror

设置好之后,执行下sudo apt update

安装需要的库

php 复制代码
# 编译jar 用 11
sudo apt install default-jdk
# 鸿蒙的 ohsdkmgr 命令要用 17, 等后面编译了 jar 之后再切换到 17
# sudo apt install openjdk-17-jdk

# linux 
sudo apt install unzip
sudo apt install npm
sudo apt install cmake
sudo apt install clang
sudo apt install pkg-config
sudo apt install libgtk-3-dev
sudo apt install ninja-build

去下载 node-v14.19.1-linux-x64.tar.xzgradle-7.1-bin.zip 解压之后。

你的用户下面有一个 .bashrc 文件,vscode 里面直接打开,文件最后填入

bash 复制代码
# grade
export PATH=/home/zmtzawqlp/ohos/tools/gradle-7.1/bin:$PATH
# nodejs
export NODE_HOME=/home/zmtzawqlp/ohos/tools/node-v14.19.1-linux-x64
export PATH=$NODE_HOME/bin:$PATH

保存,并且执行source .bashrc 使之生效。

代理

Clash 为例子,打开 Allow LAN System Proxy

.bashrc 最后添加以下配置,保存,并且执行source .bashrc 使之生效。

bash 复制代码
# 代理
hostip=$(cat /etc/resolv.conf |grep -oP '(?<=nameserver\ ).*')
export https_proxy="http://${hostip}:7890"
export http_proxy="http://${hostip}:7890"
export all_proxy="socks5://${hostip}:7890"

depot_tools

下载 depot_tools (commondatastorage.googleapis.com)

.bashrc 中配置

bash 复制代码
# depot_tools
export PATH=/home/zmtzawqlp/ohos/flutter/depot_tools:$PATH

保存,并且执行source .bashrc 使之生效。

同步引擎代码

创建 engine 目录,创建文件 .gclient

内容如下:

ini 复制代码
solutions = [
  {
    "managed": False,
    "name": "src/flutter",
    "url": "git@gitee.com:zmtzawqlp/flutter_engine.git",
    "custom_deps": {},
    "deps_file": "DEPS",
    "safesync_url": "",
  },
]

gitee.com:zmtzawqlp/flutter_engine.git 是我 forkOpenHarmony-SIG/flutter_engine (gitee.com)Gitee SSH Key 避免下载没权限。

engine 目录下面执行gclient sync,最终同步完成之后的文件目录长这样子。

先放下这个,在编译引擎之后还需要去下载鸿蒙的 sdk

鸿蒙 SDK

HUAWEI DevEco Studio和SDK下载和升级 | HarmonyOS开发者 这个页面去下载 Command Line Tools for OpenHarmony 下面的 linux 版本

解压之后,目录是这样的。

将下面的配置加到 .bashrc 中,保存,并且执行source .bashrc 使之生效。

bash 复制代码
export OHPM_HOME=/home/zmtzawqlp/ohos/tools/oh-command-line-tools/ohpm/
export OHOS_SDK_HOME=/home/zmtzawqlp/ohos/tools/sdk
export HDC_HOME=/home/zmtzawqlp/ohos/tools/sdk/10/toolchains
export PATH=$PATH:$HDC_HOME
export PATH=$PATH:$OHPM_HOME/bin
export PATH=/home/zmtzawqlp/ohos/tools/oh-command-line-tools/sdkmanager/bin:$PATH

执行 ohsdkmgr list(如果报错 java 版本错误,先执行 sudo apt install openjdk-17-jdk),你们应该只能看到 9,8,7. 我们这里直接去官方下载 10 的 sdk。

每日构建 | OpenHarmony CI

去找 4.0 以上的 sdk,我这边下载的是 download.ci.openharmony.cn/version/Mas...

下载之后以这个层级放

至于原因,因为配置里面默认设置

分别进入 sdk/10/ets/build-tools/ets-loadersdk/10/js/build-tools/ace-loader 执行npm install。这是因为对于不是通过 ohsdkmgr 安装的 sdk ,需要我们手动执行。如何替换full-SDK (openharmony.cn) 中有提到。

编译引擎

sdknative 文件夹复制到引擎文件夹的 ndk/linux/4.0 下面,文档中少说了 linux,但我看了下 ohos.sh 中的配置,应该是 engine/ndk/linux/4.0

在执行 make 命令之前,去下面的文件中

找到 default_warning_flagsdefault_warning_flags_cc 定义的地方,加上 -Wno-sign-compare

如果不加这个的话编译会失败,报错信如下:

ruby 复制代码
--sysroot=/home/zmtzawqlp/ohos/flutter/engine/ndk/linux/4.0/native/sysroot -Wstring-conversion -Wnewline-eof -O0 -g2 -Werror -Wall -Wextra -Wno-unused-parameter -Wno-unused-private-field -Wnon-virtual-dtor -Wvla -Woverloaded-virtual -Wno-comments -g3 -ggdb3 -fno-rtti -fno-exceptions -Wimplicit-fallthrough -fno-strict-vtable-pointers -O3 -fvisibility=hidden -fvisibility-inlines-hidden -std=c++17 -fno-rtti -nostdinc++ -nostdinc++ -fvisibility=hidden -fno-exceptions -c ../../third_party/dart/runtime/bin/socket_base_posix.cc -o obj/third_party/dart/runtime/bin/gen_snapshot_dart_io_product.socket_base_posix.o
../../third_party/dart/runtime/bin/socket_base_posix.cc:154:12: error: comparison of integers of different signs: 'unsigned long' and 'long' [-Werror,-Wsign-compare]
    cmsg = CMSG_NXTHDR(&msg, cmsg);
           ^~~~~~~~~~~~~~~~~~~~~~~
/home/zmtzawqlp/ohos/flutter/engine/ndk/linux/4.0/native/sysroot/usr/include/sys/socket.h:360:44: note: expanded from macro 'CMSG_NXTHDR'
        __CMSG_LEN(cmsg) + sizeof(struct cmsghdr) >= __MHDR_END(mhdr) - (unsigned char *)(cmsg) \
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../third_party/dart/runtime/bin/socket_base_posix.cc:160:15: error: comparison of integers of different signs: 'unsigned long' and 'long' [-Werror,-Wsign-compare]
       cmsg = CMSG_NXTHDR(&msg, cmsg), control_message++) {
              ^~~~~~~~~~~~~~~~~~~~~~~
/home/zmtzawqlp/ohos/flutter/engine/ndk/linux/4.0/native/sysroot/usr/include/sys/socket.h:360:44: note: expanded from macro 'CMSG_NXTHDR'
        __CMSG_LEN(cmsg) + sizeof(struct cmsghdr) >= __MHDR_END(mhdr) - (unsigned char *)(cmsg) \
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../third_party/dart/runtime/bin/socket_base_posix.cc:263:33: error: comparison of integers of different signs: 'unsigned long' and 'long' [-Werror,-Wsign-compare]
         i++, message++, cmsg = CMSG_NXTHDR(&msg, cmsg)) {
                                ^~~~~~~~~~~~~~~~~~~~~~~
/home/zmtzawqlp/ohos/flutter/engine/ndk/linux/4.0/native/sysroot/usr/include/sys/socket.h:360:44: note: expanded from macro 'CMSG_NXTHDR'
        __CMSG_LEN(cmsg) + sizeof(struct cmsghdr) >= __MHDR_END(mhdr) - (unsigned char *)(cmsg) \
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3 errors generated.
[47/7889] CXX obj/third_party/dart/runtime/bin/gen_snapshot_dart_io_product.sync_socket.o
ninja: build stopped: subcommand failed.
xargs: sh: exited with status 255; aborting
make: *** [Makefile:16: ohos] Error 124

问了 ChatGPT ,这是因为 C++ 编译中配置了 -Werror 将警告当作错误抛出。可以增加 -Wno-sign-compare 来忽略该警告。

在错误日志里面,确实能看到 -Werror 参数。

ini 复制代码
 --sysroot=/home/zmtzawqlp/ohos/flutter/engine/ndk/linux/4.0/native/sysroot -Wstring-conversion -Wnewline-eof -O0 -g2 -Werror -Wall -Wextra -Wno-unused-parameter -Wno-unused-private-field -Wnon-virtual-dtor -Wvla -Woverloaded-virtual -Wno-comments -g3 -ggdb3 -fno-rtti -fno-exceptions -Wimplicit-fallthrough -fno-strict-vtable-pointers -O3 -fvisibility=hidden -fvisibility-inlines-hidden -std=c++17 -fno-rtti -nostdinc++ -nostdinc++ -fvisibility=hidden -fno-exceptions -c 

试了下给编译选项加上 make 命令加上 -Wno-sign-compare,依然报错。看来选项应该在某个地方被重写了。通过日志里面这些编译选项 -Wstring-conversion -Wnewline-eof -O0 -g2 -Werror -Wall -Wextra -Wno-unused-parameter -Wno-unused-private-field -Wnon-virtual-dtor -Wvla -Woverloaded-virtual -Wno-comments -g3 -ggdb3 -fno-rtti -fno-exceptions -Wimplicit-fallthrough -fno-strict-vtable-pointers -O3 -fvisibility=hidden -fvisibility-inlines-hidden -std=c++17 -fno-rtti -nostdinc++ -nostdinc++ -fvisibility=hidden -fno-exceptions -c,很快就定位到了 engine/src/build/config/compiler/BUILD.gn 这个文件。

修改之后,到 engine 文件夹下面执行 make

对了,如果编译的过程中出现下面的错误,记得先把代理关闭了。

less 复制代码
The compiler crashed: SocketException: Connection timed out (OS Error: Connection timed out, errno = 110), address = 127.0.0.1, port = 39562
#0      _NativeSocket.startConnect (dart:io-patch/socket_patch.dart:694:35)
#1      _RawSocket.startConnect (dart:io-patch/socket_patch.dart:1855:26)
#2      RawSocket.startConnect (dart:io-patch/socket_patch.dart:27:23)
#3      Socket._startConnect (dart:io-patch/socket_patch.dart:2078:22)
#4      Socket.startConnect (dart:io/socket.dart:763:21)
#5      _ConnectionTarget.connect (dart:_http/http_impl.dart:2466:20)
#6      _HttpClient._getConnection.connect (dart:_http/http_impl.dart:2906:12)
#7      _HttpClient._getConnection (dart:_http/http_impl.dart:2911:12)
#8      _HttpClient._openUrl (dart:_http/http_impl.dart:2766:12)
#9      _HttpClient.openUrl (dart:_http/http_impl.dart:2604:7)
#10     _WebSocketImpl.connect (dart:_http/websocket_impl.dart:1021:42)
#11     WebSocket.connect (dart:_http/websocket.dart:320:22)
#12     vmServiceConnectUri (package:vm_service/vm_service_io.dart:32:44)
#13     _currentHeapCapacity (package:compiler/src/common/ram_usage.dart:27:41)
<asynchronous suspension>
#14     currentHeapCapacityInMb (package:compiler/src/common/ram_usage.dart:38:20)
<asynchronous suspension>
#15     compile.compilationDone (package:compiler/src/dart2js.dart:1067:12)
<asynchronous suspension>
#16     main (package:compiler/src/dart2js.dart:1424:3)
<asynchronous suspension>

最后成功之后,ohos_debug_unopt_arm64ohos_release_arm64 便是编译出来的产物。

下载 Flutter 配置环境

git clone https://gitee.com/openharmony-sig/flutter_flutter.git

.bashrc 最后添加以下配置,保存,并且执行source .bashrc 使之生效。

bash 复制代码
export PATH=/home/zmtzawqlp/ohos/flutter/flutter_flutter/bin:$PATH
export PATH=/home/zmtzawqlp/ohos/flutter/flutter_flutter/bin/cache/dart-sdk/bin:$PATH
export PATH="$PATH":"$HOME/.pub-cache/bin"
export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn

鸿蒙签名

git clone https://gitee.com/openharmony/developtools_hapsigner.git

autosign

进入 developtools_hapsigner/autosign,执行 命令 chmod 777 *.sh

  • .bashrc 最后添加以下配置,保存,并且执行source .bashrc 使之生效。

export SIGN_TOOL_HOME=/home/zmtzawqlp/ohos/tools/developtools_hapsigner/autosign

  • 增加 profile_tmp_template.json 内容如下, 其中 {{ohosId}} 为你等会创建的 Flutter 应用的名称。
swift 复制代码
{
    "version-name": "2.0.0",
    "version-code": 2,
    "app-distribution-type": "os_integration",
    "uuid": "5027b99e-5f9e-465d-9508-a9e0134ffe18",
    "validity": {
        "not-before": 1594865258,
        "not-after": 1689473258
    },
    "type": "release",
    "bundle-info": {
        "developer-id": "OpenHarmony",
        "distribution-certificate": "-----BEGIN CERTIFICATE-----\nMIICSTCCAc+gAwIBAgIFAJV7uNUwCgYIKoZIzj0EAwIwYzELMAkGA1UEBhMCQ04x\nFDASBgNVBAoMC09wZW5IYXJtb255MRkwFwYDVQQLDBBPcGVuSGFybW9ueSBUZWFt\nMSMwIQYDVQQDDBpPcGVuSGFybW9ueSBBcHBsaWNhdGlvbiBDQTAeFw0yMjAxMjkw\nNTU0MTRaFw0yMzAxMjkwNTU0MTRaMGgxCzAJBgNVBAYTAkNOMRQwEgYDVQQKDAtP\ncGVuSGFybW9ueTEZMBcGA1UECwwQT3Blbkhhcm1vbnkgVGVhbTEoMCYGA1UEAwwf\nT3Blbkhhcm1vbnkgQXBwbGljYXRpb24gUmVsZWFzZTBZMBMGByqGSM49AgEGCCqG\nSM49AwEHA0IABAW8pFu7tHGUuWtddD5wvazc1qN8ts9UPZH4pecbb/bSFWKh7X7R\n/eTVaRrCTSSdovI1dhoV5GjuFsKW+jT2TwSjazBpMB0GA1UdDgQWBBScyywAaAMj\nI7HcuIS42lvZx0Lj+zAJBgNVHRMEAjAAMA4GA1UdDwEB/wQEAwIHgDATBgNVHSUE\nDDAKBggrBgEFBQcDAzAYBgwrBgEEAY9bAoJ4AQMECDAGAgEBCgEAMAoGCCqGSM49\nBAMCA2gAMGUCMFfNidGo6uK6KGT9zT1T5bY1NCHTH3P3muy5X1xudOgxWoOqIbnk\ntmQYB78dxWEHLQIxANfApAlXAD/0hnyNC8RDzfLOPEeay6jU9FXJj3AoR90rwZpR\noN9sYD6Oks4VGRw6yQ==\n-----END CERTIFICATE-----\n",
        "bundle-name": "{{ohosId}}",
        "apl": "normal",
        "app-feature": "hos_normal_app"
    },
    "acls": {
        "allowed-acls": [
            ""
        ]
    },
    "permissions": {
        "restricted-permissions": []
    },
    "issuer": "pki_internal"
  }
  • 编辑 autosign.config createAppCertAndProfile.config ,修改值:sign.profile.inFile=profile_tmp.json

hapsigntool

进入 developtools_hapsigner/hapsigntool 执行 gradle build 或者 gradle jar。注意 该工具基于Gradle 7.1编译构建,请确认环境已安装配置Gradle环境,并且版本正确

前面安装库已经让下载 gradle 7.1 了,这里还需要注意的 gradle7.1需要jdk11,ohsdkmgr 必须jdk17+.用完切回 17

bash 复制代码
# 编译jar 用 11
sudo apt install openjdk-11-jdk
# 鸿蒙的 ohsdkmgr 命令要用 17, 等后面编译了 jar 之后再切换到 17
# sudo apt install openjdk-17-jdk

确保 hap-sign-tool.jar 生成

检查

执行 flutter doctor -v , 跟 FlutterOpenHarmony 应该都要 ok 才行。

vbnet 复制代码
zmtzawqlp@localhost:~$ flutter doctor -v
Flutter assets will be downloaded from https://storage.flutter-io.cn. Make sure you trust this source!
[!] Flutter (Channel master, 0.0.0-unknown, on Ubuntu 22.04.2 LTS 5.15.90.1-microsoft-standard-WSL2, locale C.UTF-8)
    ! Flutter version 0.0.0-unknown on channel master at /home/zmtzawqlp/ohos/flutter/flutter_flutter
      Cannot resolve current version, possibly due to local changes.
      Reinstall Flutter by following instructions at https://flutter.dev/docs/get-started/install.
    • Upstream repository https://gitee.com/openharmony-sig/flutter_flutter.git
    • FLUTTER_GIT_URL = https://gitee.com/openharmony-sig/flutter_flutter.git
    • Framework revision 2a83a1a976 (29 hours ago), 2023-09-23 09:43:51 +0000
    • Engine revision 1a65d409c7
    • Dart version 2.19.6
    • DevTools version 2.20.1
    • Pub download mirror https://pub.flutter-io.cn
    • Flutter download mirror https://storage.flutter-io.cn
    • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to
      perform update checks and upgrades.

[✓] OpenHarmony toolchain - develop for OpenHarmony devices
    • OpenHarmony Sdk location: /home/zmtzawqlp/ohos/tools/sdk, available api versions has [10]
    • hdc version 1.3.0
    • ohpm version 1.2.0
    • signTool location:/home/zmtzawqlp/ohos/tools/developtools_hapsigner/autosign

[✗] Android toolchain - develop for Android devices
    ✗ Unable to locate Android SDK.
      Install Android Studio from: https://developer.android.com/studio/index.html
      On first launch it will assist you in installing the Android SDK components.
      (or visit https://flutter.dev/docs/get-started/install/linux#android-setup for detailed instructions).
      If the Android SDK has been installed to a custom location, please use
      `flutter config --android-sdk` to update to that location.


[✗] Chrome - develop for the web (Cannot find Chrome executable at google-chrome)
    ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.

[✓] Linux toolchain - develop for Linux desktop
    • Ubuntu clang version 14.0.0-1ubuntu1.1
    • cmake version 3.22.1
    • ninja version 1.10.1
    • pkg-config version 0.29.2

[!] Android Studio (not installed)
    • Android Studio not found; download from https://developer.android.com/studio/index.html
      (or visit https://flutter.dev/docs/get-started/install/linux#android-setup for detailed instructions).

[!] Proxy Configuration
    • HTTP_PROXY is set
    ! NO_PROXY is not set

[✓] Connected device (1 available)
    • Linux (desktop) • linux • linux-x64 • Ubuntu 22.04.2 LTS 5.15.90.1-microsoft-standard-WSL2

[✓] HTTP Host Availability
    • All required HTTP hosts are available

创建编译项目

flutter create --platforms ohos flutter_ohos

看到 ohos 文件夹是不是跟看到 iosandroid 一样亲切。

flutter_ohos 是项目的名字,记得把 profile_tmp_template.json 中的 {{ohosId}} 替换成 flutter_ohos

.npmrc 文件

直接运行会报错,会报找不到 .npmrc 文件,你需要去 /home/zmtzawqlp/.npmrc 创建 .npmrc 文件。

并且增加以下内容,(配置开发环境-HarmonyOS应用开发)

shell 复制代码
### 仓库配置,支持配置多个地址,使用英文逗号分割
# registry=https://repo.harmonyos.com/ohpm/
registry=https://repo.huaweicloud.com/repository/npm/
@ohos:registry=https://repo.harmonyos.com/npm/
## 支持配置含有group的仓库,优先匹配
#@group1:registry=
#@group2:registry=

### 代理配置
# no_proxy=
# http_proxy=
# https_proxy=

### 证书校验配置
## 是否校验https仓库的证书,取值:true|false, default: true, 为true时需要配置ca_files证书路径
# strict_ssl=true
# #ca_files=

# ### 发布配置
# ## 因为registry支持配置多仓,所以此处需明确指定发布仓
# publish_registry=https://repo.harmonyos.com/ohpm/
# ## 用户发布三方库的发布id,从云端个人中心获取
# #publish_id=
# ## 用户私钥文件路径,公钥需在云端进行配置
# #key_path=

# ### 缓存路径, 默认在用户目录下的.ohpm/cache
# #cache=

# ### 日志级别, 取值:debug|info|warn|error, default: info
# log_level=info

# ### 网络请求超时时间, 单位ms, 默认为60s
# fetch_timeout=60000

执行编译命令

执行 flutter build hap --local-engine-src-path /home/zmtzawqlp/ohos/flutter/engine/src --local-engine ohos_release_arm64 或者 flutter build hap --local-engine-src-path /home/zmtzawqlp/ohos/flutter/engine/src --local-engine ohos_debug_unopt_arm64

生成产物的地方跟 Flutter 的不一样,不是在 build 下面。而是在 flutter_ohos/ohos/entry/build/default/outputs/default/entry-default-signed.hap

.bashrc 最终配置

大家在开始的时候,可以先把下面的内容都放进去 .bashrc 中,然后根据自己的用户名,以及下载 sdkengine 的位置做对应改变。

ini 复制代码
# flutter
export PATH=/home/zmtzawqlp/ohos/flutter/flutter_flutter/bin:$PATH
export PATH=/home/zmtzawqlp/ohos/flutter/flutter_flutter/bin/cache/dart-sdk/bin:$PATH
export PATH="$PATH":"$HOME/.pub-cache/bin"
export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn


# depot_tools
export PATH=/home/zmtzawqlp/ohos/flutter/depot_tools:$PATH

# grade
export PATH=/home/zmtzawqlp/ohos/tools/gradle-7.1/bin:$PATH

# ohos
export SIGN_TOOL_HOME=/home/zmtzawqlp/ohos/tools/developtools_hapsigner/autosign
export OHPM_HOME=/home/zmtzawqlp/ohos/tools/oh-command-line-tools/ohpm/
export OHOS_SDK_HOME=/home/zmtzawqlp/ohos/tools/sdk
export HDC_HOME=/home/zmtzawqlp/ohos/tools/sdk/10/toolchains
export PATH=$PATH:$HDC_HOME
export PATH=$PATH:$OHPM_HOME/bin
# nodejs
export NODE_HOME=/home/zmtzawqlp/ohos/tools/node-v14.19.1-linux-x64
export PATH=$NODE_HOME/bin:$PATH
export PATH=/home/zmtzawqlp/ohos/tools/oh-command-line-tools/sdkmanager/bin:$PATH

# 代理
hostip=$(cat /etc/resolv.conf |grep -oP '(?<=nameserver\ ).*')
export https_proxy="http://${hostip}:7890"
export http_proxy="http://${hostip}:7890"
export all_proxy="socks5://${hostip}:7890"

结语

本篇是只是一个探索,没有结论,因为目前只能用 Api10 (OpenHarmony 4.0) 的设备进行安装,模拟器只支持到 Api9,并且华为升级到 (HarmonyOS 4.0) 的设备也不行。只有那种合作伙伴拿到工程机开发板能跑,如果哪个小伙伴有条件的话,可以帮忙试试,谢谢。安装包我放群文件里面,欢迎大家加入 HarmonyCandies QQ群:981630644

目前接触下来和听到其他适配鸿蒙的小伙伴的反馈,鸿蒙现在对于开发者来说,就像个毛坯房。 不知道今天下午,是否会听到 遥遥领先 的声音,但是不改善开发体验和解决国内厂商合作问题的话,HarmonyOS Next 是否真的能成功呢?

我摸了摸我吃灰的 1520 ,叹了一口气。

相关推荐
鸿蒙程序媛2 分钟前
【鸿蒙开发】第十三章 ArkTS基础类库-容器(数据结构)
harmonyos
Acacia.~20 分钟前
第八章 利用CSS制作导航栏
前端·css
摆烂工程师43 分钟前
GPT4变笨了?教你解决GPT4降智问题!同时封装了个Chrome扩展程序进行检查GPT
前端·后端·程序员
编程老船长44 分钟前
网页设计基础 第十九讲:CSS定位实战 —— 打造精美布局的个人简介页
前端·css·html
snow_wind_rain1 小时前
网页作业9
前端·css·css3
zhzhzhen_1 小时前
如何在项目中用elementui实现分页器功能
前端·javascript·elementui
向明天乄1 小时前
elementui el-table中给表头 el-table-column 加一个鼠标移入提示说明
前端·javascript·vue.js·elementui
Akiiiira1 小时前
【网页设计】CSS3 进阶(动画篇)
前端·javascript·css3
蒜蓉大猩猩2 小时前
Vue3.js - 一文看懂Vuex
前端·javascript·vue.js·前端框架·html5
excel2 小时前
three EdgeSplitModifier
前端