HarmonyOS 集成 Flutter 问题记录
1、DevEco-Studio 升级到 DevEco-Studio NEXT Developer Beta2 5.0.3 版本之后报错:
> hvigor ERROR: Schema validate failed. Detail: Please check the following fields. { instancePath: 'modules[2].srcPath', keyword: 'pattern', params: { pattern: '^(\\./|\\.\\./)[\\s\\S]+$' }, message: 'must match pattern "^(\\./|\\.\\./)[\\s\\S]+$"', location: '/Users/XXX/huifu/merohos-flutter-demo/.ohos/build-profile.json5:55:112' }
规避方案:
1. 去掉 srcPath 路径校验:
找到工程目录下configuration-->build-profile.json5文件中的"modules"-->"srcPath"属性,然后按住Ctrl键,鼠标左键点击"srcPath"属性,进入到ohos-project-build-profile-schema.json文件中,将其中"properties"-->"srcPath"属性括号中的正则校验删掉,修改如下
将
"type": "string", "pattern": "^(./|..//)[\s\S]+$" 改为 "type": "string"
2. 此时可能还是继续报错:
/Applications/DevEco-Studio.app/Contents/tools/node/bin/node /Applications/DevEco-Studio.app/Contents/tools/hvigor/bin/hvigorw.js --sync -p product=default --analyze=normal --parallel --incremental --daemon > hvigor hvigor client: Starting hvigor daemon. > hvigor Hvigor Daemon started in 180 ms > hvigor ERROR: Cannot find belonging project path for module at / > hvigor ERROR: BUILD FAILED in 476 ms Process finished with exit code 255
规避方案:
替换开发工具文件方法:
1). 找到这个文件:/Applications/DevEco-Studio.app/Contents/tools/hvigor/hvigor-ohos-plugin/src/model/module/core-module-model-impl.js
2). 格式化这个文件
3). 修改方法 findBelongProjectPath(e)修改
```js // ... findBelongProjectPath(e) { if (e === path_1.default.dirname(e)) { // throw Error(`Cannot find belonging project path for module at ${e}`); return this.parentProject.getProjectDir(); } // ... }