编译构建时报错的常见配置类错误汇总如下:
问题现象 | 问题原因 |
|---|---|
构建报错:hvigor ERROR: 00303038 Configuration Error Schema validate failed. | Schema校验失败。 |
构建报错:The type of the target device does not match the deviceType configured in the module.json5 file of the selected module. | targets的deviceType和module.json5中的deviceTypes不匹配。 |
构建报错:hvigor ERROR: EINVAL: invalid argument. | 项目文件路径过长,导致SDK的路径拼接失效。 |
构建报错:hvigor ERROR: Tools execution failed. spawn Unknown system error -86. | Command Line Tools与DevEco Studio的版本未配套使用。 |
构建报错:hvigor ERROR: Debug Failure. False expression: Script kind should match provided ScriptKind and sourceFile.scriptKind. | 文件扩展名与编译器内部标记的脚本类型不一致。 |
构建报错:hvigor ERROR:The @ohos/hvigor-ohos-plugin version () is not within the expected range 2.xx(2.xx >= 2.4.0) | 内置的hvigor依赖版本不正确。 |
构建报错:Unknown resource name 'XXX'. | 资源没有定义。 |
SDK未找到。 |

项目在Mac上的DevEco Studio上正常运行,放到Windows 11上的DevEco Studio运行报错:
hvigor ERROR: EINVAL: invalid argument, mkdir 'xxx\xxx\...\debug
> hvigor ERROR: Failed :entry:main_sit@CompileResource... > hvigor ERROR: Tools execution failed. spawn Unknown system error -86 > hvigor ERROR: BUILD FAILED in 4 s 333 ms. > hvigor ERROR: comp_platform_api:default@ProcessLibs is not an incremental task. > hvigor ERROR: comp_router:default@ProcessLibs is not an incremental task. > hvigor ERROR: comp_pullrefresh:default@ProcessLibs is not an incremental task.
常见报错日志如下:
> hvigor ERROR: Debug Failure. False expression: Script kind should match provided ScriptKind:8 and sourceFile.scriptKind: 3, !entry: false
COMPILE RESULT:FAIL {ERROR:1}
> hvigor ERROR: BUILD FAILED in 5 s 855 ms
Process finished with exit code -1 或者:
> hvigor ERROR: Debug Failure. False expression: Script kind should match provided ScriptKind:3 and sourceFile.scriptKind: 8, !entry: false
COMPILE RESULT:FAIL {ERROR:1} > hvigor Finished :entry:default@BuildJS... after 5 ms > hvigor ERROR: Failed :entry:default@HotReloadArkTS... > hvigor ERROR: ArkTS:ERROR File: /Users/xxx/Desktop/code/demo-flutter/ohos/entry/src/main/ets/form/provider/ImageProvider.ets:26:17 Unknown resource name 'gcar\_default\_vehicle\_v446k'. > hvigor ERROR: BUILD FAILED in 47 s 787 ms
根据报错信息,可以确认是模块级build-profile.json5文件中targets下指定的deviceType字段不是src/main/module.json5中配置的deviceTypes字段的子集。
检查项目文件路径是否过长。Windows系统的文件路径长度限制为260个字符(包括盘符和反斜杠)。超过这个限制的路径可能会导致各种问题,包括应用程序无法正确处理。在处理超长路径时,Windows系统会在路径的起始部分拼接一个正斜杠(/)或者问号(?)来解决这个问题。
排查Command Line Tools的版本与DevEco Studio的版本是否一致。
根据报错信息可知,文件扩展名与编译器内部标记的脚本类型不一致,常见于DevEco Studio构建的缓存问题。
根据报错信息可知,内置的hvigor依赖版本不正确。
根据错误信息可知,对应资源_v446k未定义。
根据报错的资源标签到entry\src\main\resources\base目录下查看该资源是否存在,如果是图片资源在media子目录,如果是字符串在element子目录,不存在的话需要补充对应的资源。