鸿蒙版Flutter环境搭建

2024-11-05 23:13:20
185次阅读
0个评论
最后修改时间:2024-11-05 23:15:29

鸿蒙版Flutter环境搭建

flutter_flutter项目,这是我们整个工程的核心,但是很多人都倒在了第一步,其原因,就是——需要使用Dev分支!!!

https://gitee.com/openharmony-sig/flutter_flutter/tree/dev/

注意事项

(1)目前支持操作系统Linux、Mac、Windows环境下使用 (2)mac系统在终端输入"uname -m"判断系统架构选择对应的开发组件套 如果输出结果是 x86_64,则表示你的系统是x86-64架构 如果输出结果是 arm64,则表示你的系统是arm64架构

我的电脑是arm

(3)IDE使用官方下载地址 最新套件更加稳定,性能更佳,且鸿蒙Flutter需要依赖最新套件编译

我们此次也是以mac和windows为例来展开。

下载并安装鸿蒙最新开发套件

鸿蒙开发套件官方下载地址:https://developer.huawei.com/consumer/cn/download/

下载鸿蒙版flutter

项目地址:https://gitee.com/openharmony-sig/flutter_flutter

通过代码工具下载仓库代码并指定dev或master分支,dev不断在更新相比master拥有更多功能

git clone https://gitee.com/openharmony-sig/flutter_flutter.git
git checkout -b dev origin/dev

环境变量配置

open ~/.bash_profile

export TOOL_HOME= /Applications/DevEco-Studio2.app/Contents 
export DEVECO_SDK_HOME=$TOOL_HOME/sdk 
export PATH=$TOOL_HOME/tools/ohpm/bin:$PATH 
export PATH=$TOOL_HOME/tools/hvigor/bin:$PATH 
export PATH=$TOOL_HOME/tools/node/bin:$PATH 
export PATH=/Users/jianguo/huawei/flutter_flutter/bin:$PATH
export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn

然后刷新一下

source ~/.bash_profile

这里面注意的就是找到DevEco-Studio的安装目录,因为我是本地有两个安装目录,所以这样配置。

配置完以后,我们就可以运行Flutter doctor -v来检测环境变量是否OK。

image-20240713183555890

通过上面也可以看到,我们的环境配置OK

jianguo@jianguodeMacBook-Pro-2 harmonyflutter % flutter doctor -v 
[✓] Flutter (Channel stable, 3.13.0, on macOS 13.4.1 22F82 darwin-arm64, locale zh-Hans-CN)
    • Flutter version 3.13.0 on channel stable at /Users/jianguo/development/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision efbf63d9c6 (11 个月前), 2023-08-15 21:05:06 -0500
    • Engine revision 1ac611c64e
    • Dart version 3.1.0
    • DevTools version 2.25.0
    • Pub download mirror https://pub.flutter-io.cn
    • Flutter download mirror https://storage.flutter-io.cn

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/jianguo/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • ANDROID_HOME = /Users/jianguo/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.3.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14E300c
    • CocoaPods version 1.11.0

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2022.3)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231)

[✓] VS Code (version 1.90.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.92.0

[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-arm64   • macOS 13.4.1 22F82 darwin-arm64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 126.0.6478.127

[✓] Network resources
    • All expected network resources are available.

• No issues found!

到此mac环境配置完成。

收藏00

登录 后评论。没有帐号? 注册 一个。