首页 > 其他分享 >HarmonyOS开发——编译报错“The reason and usedScene attributes are mandatory for user_grant permissions”

HarmonyOS开发——编译报错“The reason and usedScene attributes are mandatory for user_grant permissions”

时间:2024-10-10 10:49:29浏览次数:1  
标签:mandatory grant usedScene module reason 报错 user

问题现象:

DevEco Studio编译失败,提示“The reason and usedScene attributes are mandatory for user_grant permissions”。

问题原因:

从DevEco Studio NEXT Developer Preview2版本开始新增规则:APP包中,所有entry和feature hap的module下的requestPermissions权限清单必须指定(可以缺省为空,若非空则name必填,user_grant权限则必填reason、usedScene字段)。

 

解决措施:

进入对应module.json5文件中,补齐requestPermissions字段下的reason和usedScene字段。

代码示例如下:

"requestPermissions": [{
    "name": "ohos.permission.MEDIA_LOCATION",
    "reason": "$string:module_desc",
    "usedScene": {
        "abilities": [
            "EntryAbility"
        ],
        "when": "always"
    }
}]

如上,添加了 "reason": "$string:module_desc" 之后,报错就没有了,重新编译,运行成功。

标签:mandatory,grant,usedScene,module,reason,报错,user
From: https://www.cnblogs.com/xyyt/p/18455869

相关文章

  • 自动化测试 | 安装selenium教程以及(ERROR: pip‘s dependency resolver does not cur
    1.在cmd里面安装selenium输入:pipinstallselenium在我这里出现了下载缓慢的问题,一直卡了半天,有同样问题的小伙伴可以试试输入下面这个进行安装,会更快一点:pip--default-timeout=100installselenium-ihttps://pypi.tuna.tsinghua.edu.cn/simple之后仍然出现了:ERRO......
  • codeforces round 974(div.3)E(优先队列实现dijstra算法,devc++的优先队列用greater报
    解题历程:看到两边同时移动,计算最终的相遇时间,我就想到两边同时计算各点到起点的最短距离,就是使用dijstra算法,最后所有节点取两次计算的最大值,再对所有节点取最小值,就是最终答案了,可是这个思路没有考虑有马的情况,思考一番后发现可以多列一个数组记录有马的情况下的行走最短路,然后......
  • Vscode中的行尾序列CRLF/LF问题,及其引起的Delete ‘␍‘ 的报错问题
    本人使用的是Windows系统,Unix/Linux/macOS系统也可参照此方法解决问题报错如图:(如果你只想解决报错的话直接下翻到解决方法,想了解原理的话请耐心看完)在这之前,我们先来了解一下什么是行尾符(也叫换行符/行尾序列)。行尾符是用于标记文本文件中一行结束的字符,不同的操作系统使......
  • 运行CtsVerifier.apk报错
    要过GMS认证,遇到个问题。安装CtsVerifier.apk。前面几个选项都OK。可以测试成功。执行CameraITSTest的时候崩溃。查看log:r:AccessinghiddenmethodLandroid/hardware/devicestate/DeviceStateManager;->getSupportedStates()[I(blocked,test-api,linking,denied......
  • 停止训练后报错torch.cuda.OutOfMemoryError: CUDA out of memory. 及查看进程和停止
    停止训练后遇到 torch.cuda.OutOfMemoryError 错误,意味着你的GPU内存不足,无法分配更多内存给当前的PyTorch操作。查看进程并关闭相关进程就可恢复。在不同的操作系统中,查看进程的方法有所不同。以下是常见操作系统的命令:在Linux和macOS系统中,你可以使用以下几种方法来......
  • 调用sdapi/v1/txt2img接口,报错“Couldn‘t load custom C++ ops”
    后端启动stable_diffusion的api接口nohuppythonlaunch.py --use-cpuall--skip-torch-cuda-test   --api--api-log  --listen--server-name192.168.1.204>/home/third_party_app/llm/stable-diffusion-webui/logs/all.log2>&1 &服务接口http://192.168......
  • nacos gateway 调用服务报错503 Server unavailable
    环境springboot3jdk17依赖<dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-bootstrap</artifactId></dependency><dependency><groupId>org.springframe......
  • springboot-网站开发-thymeleaf引擎报错找不到指定的页面模板文件
    springboot-网站开发-thymeleaf引擎报错找不到指定的页面模板文件!这种错误的情况,发生,一般都是因为,我们自己的html模板文件,存档位置并不是在默认的templates下面。而是我们自己新建的一个子目录里面。然后,我们在java代码里面,控制器方法体内,return,返回模板的时候,我们多写了一个......
  • C# WebService返回参数为DataTable报错“XML文档有错误”
    该问题由于DataTable列存在自定义类型。解决该报错需要以下几步:1、自定义类型增加xml序列化2、由于C#从XML反序列化DataSet或DataTable时的默认限制,所以需要先把调用方的项目开放限制,如果是.netframework项目,需要在app.config中添加<configuration><runtime>......
  • 安装VUE报错
    今年在安装脚手架的时候使用命令:npminstall-g@vue/cli发现报错:requesttohttps://registry.npm.taobao.org/@vue%2fclifailed,reason:certificatehasexpired证书已过期,查看了下旧的地址已经不适用了 接解决办法:1、查看下当前的下载源:npmconfiggetregistry2.设......