编译报错“The reason and usedScene attributes are mandatory for user\_grant permissions”
===================================================================================

**问题现象**

DevEco Studio编译失败，提示“The reason and usedScene attributes are mandatory for user\_grant permissions”。

![](https://contentcenter-vali-drcn.dbankcdn.cn/pvt_2/DeveloperAlliance_scene_100_1/25/v3/7OLeVk07SJeR1DPa4NQvFw/zh-cn_image_0000002654797867.png?HW-CC-KV=V1&HW-CC-Date=20260709T134350Z&HW-CC-Expire=86400&HW-CC-Sign=B16880856DB9352CC17D380708DDB66721C2F894E6B46A8FACE9A26645CC23FF "点击放大")

**问题原因**

从DevEco Studio NEXT Developer Preview 2版本开始，新增规则：APP包中，所有entry和feature hap的module下的requestPermissions权限清单必须指定（可以为空，若非空则name必填；user\_grant权限则必填reason和usedScene字段）。

**解决措施**

进入对应module.json5文件中，补齐requestPermissions字段下的reason和usedScene字段。如以下示例：

"requestPermissions": \[
  {
    "name": "ohos.permission.READ\_IMAGEVIDEO",
    "reason": "$string:module\_desc",
    "usedScene": {
      "abilities": \[
        "EntryAbility"
      \],
      "when": "inuse"
    }
  }
\],