DEV Community

flfljh
flfljh

Posted on

HarmonyOS Flutter: Simulator Development and Debugging Steps

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
Enter fullscreen mode Exit fullscreen mode

Add HarmonyOS Support to Existing Projects

flutter create --platforms ohos .
Enter fullscreen mode Exit fullscreen mode

Signing Configuration

  1. Open the ohos directory (HarmonyOS project) in DevEco.
  2. Navigate to File → Project Structure..., select Signing 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
Enter fullscreen mode Exit fullscreen mode

Create a Simulator

1.Open Device Manager in DevEco (dropdown next to the run button).

img

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.

img

image.png

3.Start the newly created emulator.

Run the Flutter Project

  1. Ensure the simulator device (e.g., 127.0.0.1:5555(ohos-arm64)) appears in VSCode’s device list.
  2. Run the Flutter project as usual.

Troubleshooting

1. App Crashes on Startup

  • X86 Simulators: Delete FloatingActionButton in main.dart.
  • Impeller Rendering Issues: Create ohos/entry/src/main/resources/rawfile/buildinfo.json5 with:
{
   "string": [
      {
         "name": "enable_impeller",
         "value": "true"
      }
   ]
}
Enter fullscreen mode Exit fullscreen mode

2. Simulator Not Visible in VSCode

  • Restart DevEco or VSCode.
  • Ensure the ohos directory is open in DevEco.

3. Incorrect Flutter Version with FVM

  1. Configure FVM in VSCode’s settings.json:
{
  "dart.flutterSdkPath": ".fvm/versions/custom_3.22.0"
}
Enter fullscreen mode Exit fullscreen mode
{
  "flutter": "custom_3.22.0"
}
Enter fullscreen mode Exit fullscreen mode
  1. 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
Enter fullscreen mode Exit fullscreen mode

3.3 Disable global Flutter configuration in ~/.zshrc or ~/.bash_profile.

#export PATH="/Users/zacksleo/flutter/bin:$PATH"
Enter fullscreen mode Exit fullscreen mode

Top comments (0)