HarmonyOS Flutter: Simulator Development and Debugging Steps
Development computer must be an M-series chip (ARM architecture) Mac computer
Currently, Flutter HarmonyOS development does not support X86 architecture simulators and requires an ARM architecture simulator.
Create a Project
After setting up the development environment, create a project using:
flutter create --platforms ohos ohos_app
Add HarmonyOS Support to Existing Projects
flutter create --platforms ohos .
Signing Configuration
- Open the
ohos
directory (HarmonyOS project) in DevEco. - Navigate to
File → Project Structure...
, selectSigning Configs
, check Automatically generate signature, then click Sign In with your Huawei account.
> hvigor WARN: The current module 'ohos' has dependency which is not installed at its oh-package.json5.
> hvigor Finished :entry:init... after 1 ms
> hvigor Finished ::init... after 1 ms
Process finished with exit code 0
Create a Simulator
1.Open Device Manager in DevEco (dropdown next to the run button).
image.png
2.Click + New Emulator in the bottom-right corner.
- If images are not downloaded, click the download button first.
- After downloading, proceed to create the emulator.
image.png
3.Start the newly created emulator.
Run the Flutter Project
- Ensure the simulator device (e.g.,
127.0.0.1:5555(ohos-arm64)
) appears in VSCode’s device list. - Run the Flutter project as usual.
Troubleshooting
1. App Crashes on Startup
-
X86 Simulators: Delete
FloatingActionButton
inmain.dart
. -
Impeller Rendering Issues:
Create
ohos/entry/src/main/resources/rawfile/buildinfo.json5
with:
{
"string": [
{
"name": "enable_impeller",
"value": "true"
}
]
}
2. Simulator Not Visible in VSCode
- Restart DevEco or VSCode.
- Ensure the
ohos
directory is open in DevEco.
3. Incorrect Flutter Version with FVM
- Configure FVM in VSCode’s
settings.json
:
{
"dart.flutterSdkPath": ".fvm/versions/custom_3.22.0"
}
{
"flutter": "custom_3.22.0"
}
- Verify Flutter version:
Flutter 3.22.0-ohos • channel oh-3.22.0 • https://gitee.com/harmonycommando_flutter/flutter.git
Framework • revision 85630b0330 (13 天前) • 2024-10-26 02:39:47 +0000
Engine • revision f6344b75dc
Tools • Dart 3.4.0 • DevTools 2.34.1
3.3 Disable global Flutter configuration in ~/.zshrc
or ~/.bash_profile
.
#export PATH="/Users/zacksleo/flutter/bin:$PATH"
Top comments (0)