如何解决编译报错“Property xxx does not exist on type 'typeof BuildProfile'

如何解决编译报错“Property xxx does not exist on type 'typeof BuildProfile'

HarmonyOS
2024-06-13 11:26:50
5197浏览
已于2024-6-13 23:06:50修改
收藏 0
回答 1
回答 1
按赞同
/
按时间
Heiang

问题场景一:

编译态没问题,使用了自定义参数BuildProfile,编译态无异常但编译构建失败,提示“Property xxx does not exist on type 'typeof BuildProfile'.”。

解决措施:

检查在当前模块下build-profile.json5中的targets > buildProfileFields配置的自定义参数中key值是否相同,如果不同请将targets内所有buildProfileFields中的key值保持相同,如以下示例:

"targets": [ 
  { 
    "name": "default", 
    "config": { 
      "buildOption": { 
        "arkOptions": { 
          "buildProfileFields": { 
            "targetName": "default" 
          } 
        } 
      } 
    } 
  }, 
  { 
    "name": "default1", 
    "config": { 
      "buildOption": { 
        "arkOptions": { 
          "buildProfileFields": { 
            "targetName": "default1" 
          } 
        } 
      } 
    } 
  }, 
]
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.

问题场景二:

本地HSP模块对外提供的接口中使用了HAP未定义的自定义参数BuildProfileFileds,且HAP引用了HSP中的该接口,导致编译失败,提示“Property 'XX' does not exist on type 'typeof BuildProfile'”。

解决措施:

可采用以下两种方式解决该问题:

1.在HAP中配置与HSP相同的自定义参数BuildProfileFileds。

2.将与HSP相同的自定义参数BuildProfileFileds配置到工程级build-profile.json5中,该方法会使HSP中的自定义参数在全局生效。

问题场景三:

编译态标红,使用了自定义参数BuildProfile并且代码标红且构建失败,提示“Property xxx does not exist on type 'typeof BuildProfile'.”。

解决措施:

检查当前模块下build-profile.json5中buildProfileFields内是否添加了所使用的自定义参数,确保该自定义参数已配置在buildProfileFields内。

分享
微博
QQ
微信
回复
2024-06-13 22:53:35
相关问题
The <canvas> component does not exist.
9433浏览 • 3回复 待解决
HarmonyOS 2300061报错如何解决
1073浏览 • 1回复 待解决
http请求报错2300006如何解决
3971浏览 • 1回复 待解决
获取UIContext报错1300002如何解决
3378浏览 • 1回复 待解决
HarmonyOS 真机运行报错如何解决
1448浏览 • 1回复 待解决
创建Native C++项目报错如何解决
340浏览 • 0回复 待解决
真机联调报错如何解决
1351浏览 • 1回复 待解决
修改包名后报错,请问如何解决?
7089浏览 • 1回复 待解决