目录

编译报错“The reason and usedScene attributes are mandatory for user_grant permissions.”

错误描述

针对Hap模块,配置user_grant权限时必须包含reason和usedScene属性。

可能原因

在module.json5文件中配置user_grant类型的权限时,必须包含reason和usedScene属性。

解决措施

对于Hap模块,在module.json5文件的requestPermissions中添加reason和usedScene字段。

对于Har/Hsp模块,在module.json5文件的requestPermissions中添加reason字段。

示例:

"requestPermissions": [
      {
        "name": "ohos.permission.READ_IMAGEVIDEO",
        "usedScene": {
          "abilities": [
            "FormAbility"
          ]
        },
        "reason":"$string:location_permission_reason"
      }
    ]