HarmonyOS鸿蒙Next中通过commit id引用flutter模块,commit id变化后,在pubspec.yaml中更新后怎样执行命令才能使用到最新的commit

HarmonyOS鸿蒙Next中通过commit id引用flutter模块,commit id变化后,在pubspec.yaml中更新后怎样执行命令才能使用到最新的commit 【问题描述】:通过commit id 引用一个flutter 模块,commit id变化后,在 pubspec.yaml 中更新后,怎样执行命令才能使用到最新的commit 。测试时发现需要在 ohos/build-profile.json5 中删除对应的模块后,再更新才能生效?

【问题现象】:flutter clean一下再flutter pub get 重新拉取依赖后好像也不行

4 回复

开发者您好,您可以在执行flutter clean后,删除pubspec.lock文件,再重新pub get。如果以上操作仍然无法解决问题,请及时反馈。

更多关于HarmonyOS鸿蒙Next中通过commit id引用flutter模块,commit id变化后,在pubspec.yaml中更新后怎样执行命令才能使用到最新的commit的实战系列教程也可以访问 https://www.itying.com/category-92-b0.html


这样可以了,感谢大佬

执行 flutter pub get 命令即可重新解析依赖,拉取最新的 commit 版本。若仍有缓存,可先执行 flutter clean 清除构建缓存后再运行。

更新 pubspec.yaml 中的 commit id 后,直接执行 flutter clean && flutter pub get 无效,是因为 ohos/build-profile.json5 缓存了旧 commit 对应的模块引用路径(如 .har 文件或本地模块标识),工具链不会自动刷新该文件。

正确的生效步骤:

  1. 修改 pubspec.yaml 中的 commit id。
  2. 执行 flutter clean 清除旧构建产物。
  3. 删除 ohos/build-profile.json5 中对应模块的配置项,或直接删除整个文件(下次 flutter pub get 会重新生成)
  4. 执行 flutter pub get,触发依赖重新解析并生成新的 build-profile.json5

这样 Flutter 模块就会引用到最新 commit 的代码。如果不清除或重置 build-profile.json5 中的残留引用,构建时会继续指向旧缓存,导致更新不生效。

回到顶部