Flutter开发HarmonyOS鸿蒙Next应用的时候flutter run报错如何解决

发布于 1周前 作者 yibo5220 最后一次编辑是 5天前 来自 Flutter

Flutter开发HarmonyOS鸿蒙Next应用的时候flutter run报错如何解决
【任务描述】 修复flutter run报错问题 补充: 1.运行在鸿蒙4.x上系统上就没有问题,编译输出的是apk, ✓ Built build/app/outputs/flutter-apk/app-debug.apk. 2.运行在5.0.1.71版本上就版本的, 编译输出的是hap, ✓ Built ohos/entry/build/default/outputs/default/entry-default-signed.hap. 具体报错如下 【错误表现】

➜  flutter_page_sample1 git:(master) ✗ flutter run -d 127.0.0.1:5555
Launching lib/main.dart on 127.0.0.1:5555 in debug mode...
start hap build...
Running Hvigor task assembleHap...                                 37.2s
✓ Built ohos/entry/build/default/outputs/default/entry-default-signed.hap.
installing hap. bundleName: com.example.flutter_page_sample1
_installApp: cmd=[/Applications/HA-Studio.app/Contents/sdk/default/openharmony/toolchains/hdc, -t, 127.0.0.1:5555, shell, bm, install, -p, data/local/tmp/flutterInstallTemp]
  code=0, stdout=error: failed to install bundle.
code:9568347
error: install parse native so failed.
, stderr=
Uninstalling old version...
installing hap. bundleName: com.example.flutter_page_sample1
_installApp: cmd=[/Applications/HA-Studio.app/Contents/sdk/default/openharmony/toolchains/hdc, -t, 127.0.0.1:5555, shell, bm, install, -p, data/local/tmp/flutterInstallTemp]
  code=0, stdout=error: failed to install bundle.
code:9568347
error: install parse native so failed.
, stderr=
Error: Failed to install Hap again.
Error launching application on 127.0.0.1:5555.

【环境】

【flutter环境】
[!] Flutter (Channel master, 3.7.12-ohos-1.0.0, on macOS 14.4 23E214 darwin-x64, locale zh-Hans-CN)
    • Flutter version 3.7.12-ohos-1.0.0 on channel master at /Users/yulong/Desktop/harmny/flutter_flutter
    ! Warning: `flutter` on your path resolves to /Users/yulong/fvm/versions/3.3.8/bin/flutter, which is not inside your current Flutter SDK checkout at /Users/yulong/Desktop/harmny/flutter_flutter. Consider adding
      /Users/yulong/Desktop/harmny/flutter_flutter/bin to the front of your path.
    ! Warning: `dart` on your path resolves to /usr/local/Cellar/dart/2.18.3/libexec/bin/dart, which is not inside your current Flutter SDK checkout at /Users/yulong/Desktop/harmny/flutter_flutter. Consider adding
      /Users/yulong/Desktop/harmny/flutter_flutter/bin to the front of your path.
    ! Upstream repository https://gitee.com/openharmony-sig/flutter_flutter.git is not a standard remote.
      Set environment variable "FLUTTER_GIT_URL" to https://gitee.com/openharmony-sig/flutter_flutter.git to dismiss this error.
    • Framework revision 7a712dd5fd (27 hours ago), 2024-10-23 03:14:17 +0000
    • Engine revision 1a65d409c7
    • Dart version 2.19.6
    • DevTools version 2.20.1
    • Pub download mirror https://pub.flutter-io.cn
    • Flutter download mirror https://storage.flutter-io.cn
    • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.

[✓] HarmonyOS toolchain - develop for HarmonyOS devices
    • OpenHarmony Sdk at /Applications/HA-Studio.app/Contents/sdk, available api versions has [12:default]
    • Ohpm version 5.0.8
    • Node version v16.10.0
    • Hvigorw binary at /Applications/HA-Studio.app/Contents/tools/hvigor/bin/hvigorw
【flutter版本】
Flutter 3.7.12-ohos-1.0.0 • channel master • https://gitee.com/openharmony-sig/flutter_flutter.git
Framework • revision 7a712dd5fd (31 hours ago) • 2024-10-23 03:14:17 +0000
Engine • revision 1a65d409c7
Tools • Dart 2.19.6 • DevTools 2.20.1
 【模拟器版本】
127.0.0.1:5555 (mobile) • 127.0.0.1:5555                       • ohos-arm64     • Ohos OpenHarmony-5.0.1.71 (API 13)
5 回复

现在的flutter不支持 x64架构

意思是只能用真机调试的?arm架构

也可以用M芯的模拟器,注意不是英特尔的芯片的mac

那x64指令集架构的,什么时候支撑呢?(真机目前还有没有,mac也还是英特尔的)

在Flutter开发HarmonyOS鸿蒙Next应用时遇到flutter run报错的问题,通常可能由多种原因引起,包括但不限于配置错误、依赖问题、代码兼容性问题等。以下是一些基础的排查步骤:

  1. 检查环境配置:确保你的Flutter SDK、Dart SDK以及HarmonyOS SDK版本相互兼容,并且环境变量设置正确。

  2. 检查项目配置:查看pubspec.yaml文件中的依赖是否完整且版本兼容,同时确认build.gradle等配置文件是否正确配置了鸿蒙相关的插件和设置。

  3. 清理和重建:尝试运行flutter clean命令清理项目,然后重新运行flutter run

  4. 查看日志:仔细查看报错信息和日志输出,寻找可能的线索。有时候错误信息中会明确指出问题所在,如缺少文件、权限问题等。

  5. 检查代码兼容性:确保你的Flutter代码与HarmonyOS平台兼容,特别是使用了平台特有的API或功能时。

  6. 更新和重装:如果可能,尝试更新Flutter SDK和HarmonyOS SDK到最新版本,或者重新安装它们。

如果问题依旧没法解决请联系官网客服,官网地址是:https://www.itying.com/category-93-b0.html

回到顶部