HarmonyOS 鸿蒙Next中 uniapp 导入 uni.setUserCaptureScreen 子组件后打包报错 hvigor ERROR: ArkTS Compiler Error Cannot find name 'UTSHarmony'. 已解决

HarmonyOS 鸿蒙Next中 uniapp 导入 uni.setUserCaptureScreen 子组件后打包报错 hvigor ERROR: ArkTS Compiler Error Cannot find name ‘UTSHarmony’. 已解决

23:36:11.931 打包生成 .hap ..........

23:36:35.834 > hvigor ERROR: ArkTS Compiler Error

1 WARN: ArkTS:WARN File: F:/softdata/uniapp/cxtk/unpackage/debug/app-harmony@1.3.7/entry/src/main/ets/uts/uts.ets:8:72
 Usage of 'ESObject' type is restricted (arkts-limited-esobj)

2 WARN: ArkTS:WARN File: F:/softdata/uniapp/cxtk/unpackage/debug/app-harmony@1.3.7/entry/src/main/ets/uts/uts.ets:12:33
 Usage of 'ESObject' type is restricted (arkts-limited-esobj)

3 WARN: ArkTS:WARN File: F:/softdata/uniapp/cxtk/unpackage/debug/app-harmony@1.3.7/entry/src/main/ets/uts/uts.ets:12:44
 Usage of 'ESObject' type is restricted (arkts-limited-esobj)

4 WARN: ArkTS:WARN File: F:/softdata/uniapp/cxtk/unpackage/debug/app-harmony@1.3.7/entry/src/main/ets/uts/uts.ets:24:39
 Usage of 'ESObject' type is restricted (arkts-limited-esobj)

5 WARN: ArkTS:WARN File: F:/softdata/uniapp/cxtk/unpackage/debug/app-harmony@1.3.7/entry/src/main/ets/uts/uts.ets:24:64
 Usage of 'ESObject' type is restricted (arkts-limited-esobj)

6 WARN: ArkTS:WARN File: F:/softdata/uniapp/cxtk/unpackage/debug/app-harmony@1.3.7/entry/src/main/ets/uts/uts.ets:25:36
 Usage of 'ESObject' type is restricted (arkts-limited-esobj)

7 WARN: ArkTS:WARN File: F:/softdata/uniapp/cxtk/unpackage/debug/app-harmony@1.3.7/entry/src/main/ets/uts/uts.ets:25:63
 Usage of 'ESObject' type is restricted (arkts-limited-esobj)

8 WARN: ArkTS:WARN File: F:/softdata/uniapp/cxtk/unpackage/debug/app-harmony@1.3.7/entry/src/main/ets/uts/uts.ets:27:31
 Usage of 'ESObject' type is restricted (arkts-limited-esobj)

9 WARN: ArkTS:WARN File: F:/softdata/uniapp/cxtk/unpackage/debug/app-harmony@1.3.7/entry/src/main/ets/uts/uts.ets:121:39
 Usage of 'ESObject' type is restricted (arkts-limited-esobj)

10 WARN: ArkTS:WARN File: F:/softdata/uniapp/cxtk/unpackage/debug/app-harmony@1.3.7/entry/src/main/ets/uts/uts.ets:138:21
 Usage of 'ESObject' type is restricted (arkts-limited-esobj)

11 WARN: ArkTS:WARN File: F:/softdata/uniapp/cxtk/unpackage/debug/app-harmony@1.3.7/entry/src/main/ets/uts/uts.ets:142:27
 Usage of 'ESObject' type is restricted (arkts-limited-esobj)

12 WARN: ArkTS:WARN File: F:/softdata/uniapp/cxtk/unpackage/debug/app-harmony@1.3.7/entry/src/main/ets/uts/uts.ets:146:24
 Usage of 'ESObject' type is restricted (arkts-limited-esobj)

13 WARN: ArkTS:WARN File: F:/softdata/uniapp/cxtk/unpackage/debug/app-harmony@1.3.7/entry/src/main/ets/uts/uts.ets:186:16
 Usage of 'ESObject' type is restricted (arkts-limited-esobj)

14 WARN: ArkTS:WARN File: F:/softdata/uniapp/cxtk/unpackage/debug/app-harmony@1.3.7/entry/src/main/ets/uts/uts.ets:195:24
 Usage of 'ESObject' type is restricted (arkts-limited-esobj)

15 WARN: ArkTS:WARN File: F:/softdata/uniapp/cxtk/unpackage/debug/app-harmony@1.3.7/entry/src/main/ets/uts/uts.ets:196:28
 Usage of 'ESObject' type is restricted (arkts-limited-esobj)

16 WARN: ArkTS:WARN File: F:/softdata/uniapp/cxtk/unpackage/debug/app-harmony@1.3.7/entry/src/main/ets/uts/uts.ets:196:56
 Usage of 'ESObject' type is restricted (arkts-limited-esobj)

17 WARN: ArkTS:WARN File: F:/softdata/uniapp/cxtk/unpackage/debug/app-harmony@1.3.7/entry/src/main/ets/uts/uts.ets:200:33
 Usage of 'ESObject' type is restricted (arkts-limited-esobj)

18 WARN: ArkTS:WARN File: F:/softdata/uniapp/cxtk/unpackage/debug/app-harmony@1.3.7/entry/src/main/ets/uts/uts.ets:205:29
 Usage of 'ESObject' type is restricted (arkts-limited-esobj)

19 WARN: ArkTS:WARN File: F:/softdata/uniapp/cxtk/unpackage/debug/app-harmony@1.3.7/entry/src/main/ets/uts/uts.ets:209:29
 Usage of 'ESObject' type is restricted (arkts-limited-esobj)

20 WARN: ArkTS:WARN File: F:/softdata/uniapp/cxtk/unpackage/debug/app-harmony@1.3.7/entry/src/main/ets/uni-app-harmony/runtime.ets:8:10
 Usage of 'ESObject' type is restricted (arkts-limited-esobj)

21 WARN: ArkTS:WARN File: F:/softdata/uniapp/cxtk/unpackage/debug/app-harmony@1.3.7/entry/src/main/ets/uni-app-harmony/runtime.ets:17:10
 Usage of 'ESObject' type is restricted (arkts-limited-esobj)

22 WARN: ArkTS:WARN File: F:/softdata/uniapp/cxtk/unpackage/debug/app-harmony@1.3.7/entry/src/main/ets/uni-app-harmony/runtime.ets:24:10
 Usage of 'ESObject' type is restricted (arkts-limited-esobj)

23 WARN: ArkTS:WARN File: F:/softdata/uniapp/cxtk/unpackage/debug/app-harmony@1.3.7/entry/src/main/ets/uni-app-harmony/runtime.ets:28:39
 Usage of 'ESObject' type is restricted (arkts-limited-esobj)

24 WARN: ArkTS:WARN File: F:/softdata/uniapp/cxtk/unpackage/debug/app-harmony@1.3.7/entry/src/main/ets/uni-app-harmony/runtime.ets:31:33
 Usage of 'ESObject' type is restricted (arkts-limited-esobj)

25 WARN: ArkTS:WARN File: F:/softdata/uniapp/cxtk/unpackage/debug/app-harmony@1.3.7/entry/src/main/ets/uni-app-harmony/runtime.ets:46:45
 Usage of 'ESObject' type is restricted (arkts-limited-esobj)

26 WARN: ArkTS:WARN File: F:/softdata/uniapp/cxtk/unpackage/debug/app-harmony@1.3.7/entry/src/main/ets/uni-app-harmony/runtime.ets:79:28
 Usage of 'ESObject' type is restricted (arkts-limited-esobj)

27 WARN: ArkTS:WARN File: F:/softdata/uniapp/cxtk/unpackage/debug/app-harmony@1.3.7/entry/src/main/ets/uni-app-harmony/uni.api.ets:125:5
 Definite assignment assertions are not supported (arkts-no-definite-assignment)

28 WARN: ArkTS:WARN File: F:/softdata/uniapp/cxtk/unpackage/debug/app-harmony@1.3.7/entry/src/main/ets/uni-app-harmony/uni.api.ets:126:5
 Definite assignment assertions are not supported (arkts-no-definite-assignment)

29 WARN: ArkTS:WARN File: F:/softdata/uniapp/cxtk/unpackage/debug/app-harmony@1.3.7/entry/src/main/ets/uni-app-harmony/uni.api.ets:127:5
 Definite assignment assertions are not supported (arkts-no-definite-assignment)

...

158 WARN: ArkTS:WARN File: F:/softdata/uniapp/cxtk/unpackage/debug/app-harmony@1.3.7/entry/src/main/ets/uni-app-harmony/uni.api.ets:860:5
 Definite assignment assertions are not supported (arkts-no-definite-assignment)

1 ERROR: ArkTS:ERROR File: F:/softdata/uniapp/cxtk/unpackage/debug/app-harmony1/entry/src/main/ets/uni_modules/uni-usercapturescreen/utssdk/app-harmony/index.ets:62:17
 Cannot find name 'UTSHarmony'.

解决方案:
将uniapp 打包文件在 DevEco Studio 打开运行,然后点击报错定位到 UTSHarmony,然后右键,选择第一个解决问题,再打包就可以

更多关于HarmonyOS 鸿蒙Next中 uniapp 导入 uni.setUserCaptureScreen 子组件后打包报错 hvigor ERROR: ArkTS Compiler Error Cannot find name 'UTSHarmony'. 已解决的实战教程也可以访问 https://www.itying.com/category-93-b0.html

6 回复
1 ERROR: ArkTS:ERROR File: F:/softdata/uniapp/cxtk/unpackage/debug/app-harmony1/entry/src/main/ets/uni_modules/uni-usercapturescreen/utssdk/app-harmony/index.ets:62:17
Cannot find name 'UTSHarmony'.
 
COMPILE RESULT:FAIL {ERROR:2 WARN:418}
上面的最后代码

更多关于HarmonyOS 鸿蒙Next中 uniapp 导入 uni.setUserCaptureScreen 子组件后打包报错 hvigor ERROR: ArkTS Compiler Error Cannot find name 'UTSHarmony'. 已解决的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html


HbuilderX版本是多少?截的都是WARN日志,有没有ERROR日志?

ARKTS:ERROR
F:/softdata/uniapp/cxtk/unpackage/debug/app-harmony1/entry/src/main/ets/uni_modules/uni-usercapturescreen/utssdk/app-harmony/index.ets:62:17
Cannot find name 'UTSHarmony'.

COMPILE RESULT:FAIL {ERROR:2 WARN:418}

HbuilderX版本是4.29

在HarmonyOS Next中,使用uniapp导入uni.setUserCaptureScreen子组件后,打包时出现hvigor ERROR: ArkTS Compiler Error Cannot find name 'UTSHarmony'的错误,通常是由于ArkTS编译器未能正确识别或找到相关模块或类型定义导致的。解决方法是检查项目中的依赖配置和模块引用,确保UTSHarmony相关模块已正确导入并配置。具体操作包括:

  1. 检查依赖配置:确认build.gradlepackage.json中是否已正确添加UTSHarmony相关依赖。
  2. 模块引用:确保在代码中正确引用了UTSHarmony模块,且路径无误。
  3. 编译器配置:检查ArkTS编译器的配置,确保其能够识别UTSHarmony相关类型。
  4. 清理缓存:尝试清理项目缓存并重新编译,避免缓存导致的编译错误。

通过这些步骤,问题通常可以得到解决。如果问题仍然存在,建议进一步检查项目的具体配置和代码实现。

在HarmonyOS鸿蒙Next中,使用uniapp导入uni.setUserCaptureScreen子组件时,报错hvigor ERROR: ArkTS Compiler Error Cannot find name 'UTSHarmony',通常是由于ArkTS编译器未能正确识别或导入相关模块。解决方法如下:

  1. 检查依赖:确保项目依赖中已正确引入UTSHarmony模块,并在package.json或相关配置文件中进行声明。

  2. 更新SDK:确保使用的是最新版本的HarmonyOS SDK和uniapp插件,旧版本可能存在兼容性问题。

  3. 重新编译:清理项目并重新编译,有时缓存问题可能导致编译错误。

  4. 检查代码:确保在代码中正确导入和使用UTSHarmony相关类或方法,避免拼写错误或路径问题。

  5. 查看文档:参考官方文档或社区资源,确认UTSHarmony的正确使用方式。

回到顶部