CodeNewbie Community 🌱

Cover image for HarmonyOS Flutter in Action: 10 - FAQ Collection
shaohushuo
shaohushuo

Posted on

HarmonyOS Flutter in Action: 10 - FAQ Collection

1. What should the learning path look like, and what technologies do you need to master to be able to develop HarmonyOS Flutter

1.1 Learning and mastering Flutter development techniques, this part requires a degree in the Flutter community Flutter Development Documentation
1.2 Learn the basic concepts and knowledge of HarmonyOS, and recommend learning HarmonyOS Ecosystem Application Development White Paper, ArkTS Language, ArkUI,
HarmonyOS Lesson 1

2. MatePad app adaptation issues

If you have the problem that the app cannot fully screen on the 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

Need to add the adaptation of 'tablet' tablet devices.

If your device doesn't have full screen when running on your Matepad, you may need to delete the app, reinstall it, or restart it. Because the relevant configuration is cached, when the adaptation type changes, there is no update problem, resulting in the failure to fullscreen.

3. simulator

If there is an abnormality in the simulator, it is first important to confirm whether the real machine is operating normally to eliminate the problems of the simulator itself.

4. An error is reported when the debug version is running

Error while initializing the Dart VM

Do the following, in order
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
Run flutter clean to clear the project compilation cache
Run flutter run -d $DEVICE --debug
Enter fullscreen mode Exit fullscreen mode

5. How to change your app icon and name

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

Locate the ohos/AppScope/resources/base/element/string.json file and modify the following configurations

{
  "string": [
    {
      "name": "app_name",
      "value": "中文名称"
    }
  ]
}
Enter fullscreen mode Exit fullscreen mode

6. flutter run An error is reported when running the app, and 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 and check whether the environment variable has taken effect after the configuration is successful. Restart the command line program via 'source ~/.zshrc', or even restart the IDE/system until the variable takes effect.

7. Is it possible to use Flutter to develop meta services

Not at the moment, there is a limit to the size of the meta service (2M) and the Flutter build artifact is too large to meet this requirement

8. How to customize the display of the project name after DevEco opens ohos

For each HarmonyOS Flutter project, after opening the ohos project with DevEco, the default project name displayed is 'ohos', if you want to customize the displayed project name, you can refer to the following steps:

In the ohos/.idea directory, create a new '.name' file and write the project name.

References

Top comments (0)