HarmonyOS鸿蒙Next中构建正常,但是无法预览,报错 Cannot read properties of undefined (reading 'isSO')

HarmonyOS鸿蒙Next中构建正常,但是无法预览,报错 Cannot read properties of undefined (reading ‘isSO’)

hvigor ERROR: Failed :boyasecime:default@PreviewArkTS...
hvigor DEBUG hvigor-core-task hvigor build process will be closed with an error.
hvigor ERROR: Cannot read properties of undefined (reading 'isSO')

* Try the following:
> Check whether undefined attributes or methods are used in the hvigorconfig.ts and hvigorfile.ts files.
> Go to the official website for help
> More info: https://developer.huawei.com/consumer/cn/doc/harmonyos-faqs-V5/faqs-compiling-and-building-108-V5

> hvigor ERROR: TypeError: Cannot read properties of undefined (reading 'isSO')
    at generateOhmUrlForSourceFile (D:\devtools\DevEco Studio\tools\hvigor\hvigor-ohos-plugin\src\utils\ohmurl-utils.js:1:809)
    at D:\devtools\DevEco Studio\tools\hvigor\hvigor-ohos-plugin\src\tasks\previewer-ark-compile.js:1:3313
    at Array.forEach (<anonymous>)
    at PreviewerArkCompile.addOhmurlToHarAbility (D:\devtools\DevEco Studio\tools\hvigor\hvigor-ohos-plugin\src\tasks\previewer-ark-compile.js:1:3110)
    at PreviewerArkCompile.doTaskAction (D:\devtools\DevEco Studio\tools\hvigor\hvigor-ohos-plugin\src\tasks\previewer-ark-compile.js:1:2558)
    at async PreviewerArkCompile.<anonymous> (D:\devtools\DevEco Studio\tools\hvigor\hvigor-ohos-plugin\src\tasks\task\ohos-module-task.js:1:1810)
    at async PreviewerArkCompile.execute (D:\devtools\DevEco Studio\tools\hvigor\hvigor\src\base\external\task\core-task-impl.js:1:2191)
    at async TaskProxy.execute (D:\devtools\DevEco Studio\tools\hvigor\hvigor\src\base\internal\task\proxy\task-proxy.js:1:4683)
    at async doIncrementalTask (D:\devtools\DevEco Studio\tools\hvigor\hvigor\src\base\internal\core\incremental-task-executor.js:1:970)
    at async executeOneTask (D:\devtools\DevEco Studio\tools\hvigor\hvigor\src\base\internal\task\core\task-runner.js:1:3652)
> hvigor ERROR: BUILD FAILED in 2 s 365 ms 

我两个hap module entryapp无法预览,另一个 feature HAP 可以正常预览。另外项目构建启动没问题。

更多关于HarmonyOS鸿蒙Next中构建正常,但是无法预览,报错 Cannot read properties of undefined (reading 'isSO')的实战教程也可以访问 https://www.itying.com/category-93-b0.html

3 回复

cke_132.png

补充下我的ide版本

更多关于HarmonyOS鸿蒙Next中构建正常,但是无法预览,报错 Cannot read properties of undefined (reading 'isSO')的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html


该问题通常由预览器与当前SDK版本不匹配引起。解决方法:

  1. 确保DevEco Studio为最新版本
  2. 检查项目使用的SDK版本与预览器版本是否对应
  3. 清理项目构建缓存(删除.idea、build等目录)
  4. 重新启动预览器功能
  5. 确认项目配置文件oh-package.json5中模块依赖正确

如仍报错,可尝试创建新项目验证是否为环境问题。

这个错误通常是由于预览器在解析模块配置时出现的问题。从错误日志来看,系统在尝试读取isSO属性时遇到了undefined值,这表明某个模块的配置可能不完整或存在错误。

针对您的情况,建议检查以下几点:

  1. 确保entryapp模块的build-profile.json5配置完整,特别是module.json5中的abilities配置是否正确

  2. 检查entryapp模块的hvigorfile.ts和hvigorconfig.ts文件,确认没有使用未定义的属性或方法

  3. 比较能正常预览的feature HAP和无法预览的entryapp模块的配置差异,特别是module.json5中的配置

  4. 尝试清理项目缓存(File > Invalidate Caches/Restart)后重新构建

  5. 确认DevEco Studio版本是最新的,有时预览器问题会在新版本中修复

如果问题仍然存在,建议检查entryapp模块的资源配置和依赖关系是否正确配置。

回到顶部