HarmonyOS鸿蒙Next中flutter打包卡死问题:flutter build hap --no-tree-shake-icons -v
HarmonyOS鸿蒙Next中flutter打包卡死问题:flutter build hap --no-tree-shake-icons -v
$ flutter build hap --no-tree-shake-icons -v
[ +11 ms] Could not interpret results of "git describe": 3.22.1-0.0.pre.32
[ +447 ms] Unable to locate an Android SDK.
[ +180 ms] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'OHOSGenSnapshotArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'OHOSInternalBuildArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
[ ] Artifact Instance of 'LegacyCanvasKitRemover' is not required, skipping update.
[ +8 ms] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[ +5 ms] Flutter assets will be downloaded from xxxxx Make sure you trust this source!
[ +200 ms] Artifact Instance of 'MaterialFonts' is not required, skipping update.
[ ] Artifact Instance of 'GradleWrapper' is not required, skipping update.
[ ] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[ +22 ms] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
[ ] Artifact Instance of 'LegacyCanvasKitRemover' is not required, skipping update.
[ ] Artifact Instance of 'FlutterSdk' is not required, skipping update.
[ ] Artifact Instance of 'FlutterSdkOhos' is not required, skipping update.
[ ] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[ ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'FontSubsetArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'PubDependencies' is not required, skipping update.
[ +190 ms] Skipping pub get: version match.
[ +830 ms] start hap build...
[ +4 ms] Running Hvigor task assembleHap...
[ +286 ms] Compiling ohos_aot_bundle_release_ohos-arm64 for the Ohos...
[ +45 ms] Initializing file store
[ +53 ms] Done initializing file store
[ +366 ms] Skipping target: native_assets
[ +2 ms] Skipping target: gen_localizations
[ +3 ms] Skipping target: gen_dart_plugin_registrant
[+10220 ms] Skipping target: kernel_snapshot
[ +107 ms] Skipping target: ohos_aot_release_ohos-arm64
[ +307 ms] Skipping target: aot_ohos_asset_bundle
[ +69 ms] Skipping target: ohos_aot_bundle_release_ohos-arm64
[ ] Persisting file store
[ +18 ms] Done persisting file store
[ +38 ms] Compiling ohos_aot_bundle_release_ohos-arm64 for the Ohos... (completed in 11.2s)
[ ] copy flutter assets to project start
[ +31 ms] copy from "xxxxxxxxxxxxxx\build\ohos\flutter_assets" to "xxxxxxxxxxxxx\ohos\entry\src/main/resources/rawfile\flutter_assets"
[ +46 ms] copy flutter assets to project end
[ +1 ms] copy flutter runtime to project start
[ +77 ms] copy from "xxxxxxxxxxxxxxxxxxxxxx\flutter\bin\cache\artifacts\engine\ohos-arm64-release\flutter.har" to "xxxxxxxxxxxx\test2\ohos\har\flutter.har"
[ ] copy flutter runtime to project end
[ ] executing: [xxxxxxxxxxx\test2\ohos/] ohpm clean
一直卡死
楼主,执行flutter doctor -v看下
更多关于HarmonyOS鸿蒙Next中flutter打包卡死问题:flutter build hap --no-tree-shake-icons -v的实战系列教程也可以访问 https://www.itying.com/category-92-b0.html
在HarmonyOS鸿蒙Next中,使用flutter build hap --no-tree-shake-icons -v
命令进行Flutter打包时,可能会遇到卡死问题。这通常与以下因素有关:
-
资源处理问题:
--no-tree-shake-icons
参数禁用图标资源的优化,可能导致资源处理耗时增加,尤其是在资源文件较大或数量较多时。 -
依赖冲突:Flutter与HarmonyOS HAP打包工具链之间的依赖可能存在兼容性问题,特别是在特定版本组合下。
-
调试日志影响:
-v
参数启用详细日志输出,可能增加打包过程中的内存和CPU占用,导致卡顿或卡死。 -
工具链优化不足:HarmonyOS的Flutter工具链可能尚未完全优化,某些操作(如资源打包、代码编译)可能效率较低。
-
系统资源限制:打包过程需要较高的CPU和内存资源,若系统资源不足,可能导致卡死。
-
网络问题:如果打包过程中需要下载依赖或资源,网络不稳定可能导致进程挂起。
解决此类问题通常需要检查Flutter和HarmonyOS SDK的版本兼容性,并确保系统资源充足。
在HarmonyOS鸿蒙Next中使用flutter build hap --no-tree-shake-icons
命令打包时卡死,可能是以下原因导致的:
- 依赖冲突:检查
pubspec.yaml
中的依赖是否兼容,尤其是与HarmonyOS相关的插件。 - 资源文件过大:如果项目中有大量未压缩的图片或资源,可能导致打包过程卡住。建议优化资源文件。
- Flutter版本不匹配:确保使用的Flutter版本与HarmonyOS SDK兼容。可以尝试升级Flutter到最新稳定版。
- 调试信息过多:
-v
参数会输出详细日志,可能导致内存占用过高。可以去掉-v
参数,减少日志输出。
建议:
- 清理项目缓存:
flutter clean
。 - 检查HarmonyOS SDK和工具链是否安装正确。
- 逐步排查依赖和资源文件,确保项目配置无误。
如果问题持续,建议查看详细日志或联系HarmonyOS官方支持。