CodeNewbie Community 🌱

Cover image for HarmonyOS Flutter in action: 01 - Build a development
shaohushuo
shaohushuo

Posted on

HarmonyOS Flutter in action: 01 - Build a development

Preparation

  1. Install DevEco Studio NEXT IDE, note that the version should be Next, and the latest version is Beta3

  2. Install Git, if you want to adapt to Android at the same time, you need to install Android Studio; If you want to adapt to ios, you need to install Xcode

Mac Installation (Recommended)

Environment variable configuration

# Flutter Mirror
export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn

# HarmonyOS SDK
export TOOL_HOME=/Applications/DevEco-Studio.app/Contents/
export DEVECO_SDK_HOME=$TOOL_HOME/sdk # command-line-tools/sdk
export PATH=$TOOL_HOME/tools/ohpm/bin:$PATH # command-line-tools/ohpm/bin
export PATH=$TOOL_HOME/tools/hvigor/bin:$PATH # command-line-tools/hvigor/bin
export PATH=$TOOL_HOME/tools/node/bin:$PATH # command-line-tools/tool/node/bin
Enter fullscreen mode Exit fullscreen mode

Windows installation

Configure user variables

FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn

PUB_HOSTED_URL=https://pub.flutter-io.cn

DEVECO_SDK_HOME=C:Program FilesHuaweiDevEco Studiosdk

JAVA_HOME=C:Program FilesHuaweiDevEco Studiojbr
Enter fullscreen mode Exit fullscreen mode

Configure environment variables

Edit the PATH and add the following paths

C:Program FilesHuaweiDevEco Studiotoolsohpmbin

C:Program FilesHuaweiDevEco Studiotoolshvigorbin

C:Program FilesHuaweiDevEco Studiotoolsnode

C:Program FilesHuaweiDevEco Studiojbrbin
Enter fullscreen mode Exit fullscreen mode

Manage multiple Flutter versions

If you need to use multiple versions of Flutter in your project development, you can consider using fvm

  1. Install FVM
  2. Use the official Flutter version of FVM
fvm install 3.22.0
Enter fullscreen mode Exit fullscreen mode
  1. Install the custom HarmonyOS version and go to the fvm/version directory, which is usually located in the user directory, such as '~/fvm/versions/3.22.0', Copy the repository and rename it to 'custom_x.y.z'
git clone -b dev https://gitcode.com/openharmony-sig/flutter_flutter.git custom_3.7.12
Enter fullscreen mode Exit fullscreen mode

Note that the naming format must be 'custom_x.y.z', i.e. it must start with custom_ followed by a three-digit version number, e.g. 'custom_3.7.12'

  1. Use a separate version of the Flutter SDK in your project, executed in the project directory:
fvm use custom_3.7.12
Enter fullscreen mode Exit fullscreen mode

Frequently Asked Questions

  1. Running flutter doctor gives 'Error: Unable to find git in your PATH.'

Execute the following command:

git config --global --add safe.directory '*'
Enter fullscreen mode Exit fullscreen mode

Case

! alt text

References

Top comments (0)