HarmonyOS bundleManager.getProfileByAbilitySync接口报错17700024

https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/js-apis-bundlemanager-V5#bundlemanagergetprofilebyabilitysync10

实际在module.json5中存在此值:

try { 
  let data = bundleManager.getProfileByAbilitySync('face', 'MainAbility','hwc-theme'); 
  hilog.info(0x0000, 'testTag', 'getProfileByAbilitySync successfully. Data: %{public}s', JSON.stringify(data)); 
} catch (err) { 
  let message = (err as BusinessError).message; 
  hilog.error(0x0000, 'testTag', 'getProfileByAbilitySync failed. Cause: %{public}s', message); 
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.

module.json5中内容:

"abilities": [ 
{ 
  "name": "MainAbility", 
  "srcEntry": "./ets/ability/MainAbility.ets", 
  "description": "$string:MainAbility_desc", 
  "icon": "$media:tiger", 
  "label": "$string:MainAbility_label", 
  "startWindowIcon": "$media:startIcon", 
  "startWindowBackground": "$color:start_window_background", 
  "exported": true, 
  "metadata": [ 
  { 
    "name": "theme", 
    "value": "Theme.Emui.NoActionBar" 
  } 
  ], 
  "skills": [ 
  { 
    "entities": [ 
    "entity.system.home" 
    ], 
    "actions": [ 
    "action.system.home" 
    ] 
  } 
  ] 
},
  • 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.
  • 27.
HarmonyOS
2024-08-26 16:12:54
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
superinsect

需要配置metadata中resource中的内容才可以,参考:

"metadata": [ 
{ 
  "name": "string", 
  "value": "string", 
  "resource": "$profile:metadata_con" 
} 
],
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
分享
微博
QQ
微信
回复
2024-08-26 22:34:58


相关问题
HarmonyOS 使用云存储接口报错报错
671浏览 • 1回复 待解决
HarmonyOS getaddrinfo接口调用报错
750浏览 • 1回复 待解决
HarmonyOS 内购接口调用报错
828浏览 • 1回复 待解决
HarmonyOS 调用屏幕截图接口报错801
1061浏览 • 1回复 待解决
上传文件接口报错 ,该怎么处理啊?
1548浏览 • 1回复 待解决