DEV Community

Cover image for HarmonyOS Flutter Practice: 10-Common Questions
shaohushuo
shaohushuo

Posted on

HarmonyOS Flutter Practice: 10-Common Questions

1. What should the learning path be like? What technologies need to be mastered to have the ability to develop HarmonyOS Flutter

1.1 Learn and master Flutter development technology. This requires academic qualifications in the Flutter community Flutter Development Document

1.2 Learn the basic concepts and knowledge of HarmonyOS. It is recommended to learn HarmonyOS Ecosystem Application Development White Paper, ArkTS Language, ArkUI,
HarmonyOS First Lesson

2. MatePad application adaptation problem

If the app cannot go full screen on Matepad, you need to configure the device type in ohos/entry/main/module.json5:

"deviceTypes": [ "phone", "tablet", "car", "2in1", 'default' ], 
Enter fullscreen mode Exit fullscreen mode

It is necessary to add adaptation for tablet tablet devices.

If the device does not go full screen when running on Matepad, you may need to delete the app and reinstall it or restart the device. Because the relevant configuration is cached, there is a problem of not updating when the adaptation type changes, resulting in failure to go full screen.

3. Simulator

The simulator is quite different from the real machine. If the simulator is abnormal, first confirm whether the real machine is running normally to rule out problems with the simulator itself.

4. Error when running the debug version

Error while initializing the Dart VM

Perform the following operations in sequence Set the environment variable export FLUTTER_STORAGE_BASE_URL=https://flutter-ohos.obs.cn-south-1.myhuaweicloud.com Delete the cache in the /bin/cache directory Execute flutter clean to clear the project compilation cache Run flutter run -d $DEVICE --debug 
Enter fullscreen mode Exit fullscreen mode

5. How to change the App icon and name

Find ohos/AppScope/resources/base/media/app_icon.png and replace the corresponding file

Find the ohos/AppScope/resources/base/element/string.json file and modify the following configuration

{ "string": [ { "name": "app_name", "value": "Chinese name" } ] } 
Enter fullscreen mode Exit fullscreen mode

6. flutter run App An error is reported, indicating that the command cannot be found.

Launching lib/main.dart on 127.0.0.1:5555 start hap build..-e ERROR: node: /Applications/DevEco-Studio.app/Contents/tools/ohpm/bin/ohpm: line 7: node: commandnot found -e ERROR: NODE_HOME: /Applications/DevEco-Studio.app/Contents/tools/ohpm/bin/ohpm: line 11: /node: o such file or directory -e ERROR: NODE_HOME: /Applications/DevEco-Studio.app/Contents/tools/ohpm/bin/ohpm: line 25: /bin/noc e: No such file or directory -e ERROR: Failed to find the executable ‘node’ command, please check the following possible causes:e1. Node]s is not installed.e2.'node'command not added to PATH; eand the 'Node HOME' variable is not set in the environment variables to match your NodeJsinstallation location. ProcessException: The command failedCommand: ohpm clean 
Enter fullscreen mode Exit fullscreen mode

Check the environment variable configuration. After the configuration is successful, check whether it has taken effect. Use source ~/.zshrc or restart the command line program, or even restart the IDE/system until the variable takes effect.

7. Can Flutter be used to develop meta-services?

Currently not, the size of the meta-service is limited (2M), and the Flutter build product is too large to meet this requirement.

References

Top comments (0)