OpenHarmony安装hap提示错误:install releaseType not same 原创

Emu_gem
发布于 2023-3-31 10:52
浏览
0收藏

@toc

问题分析

OpenHarmony安装hap提示错误:install releaseType not same-鸿蒙开发者社区
安装系统应用Launcher时,出现如上问题,猜想是apiReleaseType的与系统不一致。

解决方案

查看系统原先Launcher应用信息

1、使用hdc工具打开/data/app/el1/bundle/public/com.ohos.launcher/phone-launcher/module.json如下:

{"app" :{"apiReleaseType" : "Beta5","bundleName" : "com.ohos.launcher","distributedNotificationEnabled" : true,"icon" : "$media:app_icon","iconId" : 218103809,"label" : "$string:app_name","labelId" : 218103808,"minAPIVersion" : 9,"targetAPIVersion" : 9,"userDataClearable" : false,"vendor" : "ohos","versionCode" : 1000000,"versionName" : "1.0.0"},"module" :{"compileMode" : "jsbundle","deliveryWithInstall" : true,"description" : "$string:mainability_description","descriptionId" : 218103843,"deviceTypes" :["default","tablet"],"extensionAbilities" :[{"description" : "$string:mainability_description","descriptionId" : 218103843,"icon" : "$media:icon","iconId" : 218103857,"label" : "$string:entry_MainAbility","labelId" : 218103832,"name" : "com.ohos.launcher.MainAbility","priority" : 2,"skills" :[{"actions" :["action.system.home","com.ohos.action.main","action.form.publish"],"entities" :["entity.system.home","flag.home.intent.from.system"]}],"srcEntrance" : "./ets/MainAbility/MainAbility.ts","type" : "service","visible" : false}],"installationFree" : false,"mainElement" : "com.ohos.launcher.MainAbility","metadata" :[{"name" : "ArkTSPartialUpdate","value" : "true"}],"name" : "phone-launcher","pages" : "$profile:main_pages","requestPermissions" :[{"name" : "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"},{"name" : "ohos.permission.INSTALL_BUNDLE"},{"name" : "ohos.permission.LISTEN_BUNDLE_CHANGE"},{"name" : "ohos.permission.MANAGE_MISSIONS"},{"name" : "ohos.permission.REQUIRE_FORM"},{"name" : "ohos.permission.INPUT_MONITORING"},{"name" : "ohos.permission.NOTIFICATION_CONTROLLER"},{"name" : "ohos.permission.MANAGE_SECURE_SETTINGS"},{"name" : "ohos.permission.START_ABILITIES_FROM_BACKGROUND"}],"srcEntrance" : "./ets/Application/AbilityStage.ts","type" : "entry","uiSyntax" : "ets","virtualMachine" : "ark9.0.0.0"}}

其中最主要信息的是:“apiReleaseType” : “Beta5”;

修改sdk的ReleaseType

1、一开始在应用的app.json5文件中添加"apiReleaseType" :"Beta5"属性,不起作用,查阅资料后发现该属性取决于sdk本身的ReleaseType。

2、打开项目对应sdk文件夹中的oh-uni-package.json文件,根据先前查询到的信息修改"releaseType": “XXX"为"releaseType”: “Beta5”。

3、重新安装进去发现还是有同样的问题,查看build/default/outputs/default/pack.info文件如下:

{"summary":{"app":{"bundleName":"com.ohos.launcher","version":{"code":1000000,"name":"1.0.0"}},"modules":[{"mainAbility":"com.ohos.launcher.MainAbility","deviceType":["default","tablet"],"extensionAbilities":[{"name":"com.ohos.launcher.MainAbility"}],"distro":{"moduleType":"entry","installationFree":false,"deliveryWithInstall":true,"moduleName":"phone-launcher"},"apiVersion":{"compatible":9,"releaseType":"Release","target":9}}]},"packages":[{"deviceType":["default","tablet"],"moduleType":"entry","deliveryWithInstall":true,"name":"phone-launcher-default"}]}

其中重要信息为:“releaseType”:“Release”,说明先前修改的内容并没有起作用,查看设置中的sdk属性又已经更新为Beta5,最后重启应用并且新建Launcher项目,再次编译生成的pack.info文件更新了"releaseType":“Beta5”,再次安装成功!!

©著作权归作者所有,如需转载,请注明出处,否则将追究法律责任
已于2023-4-7 10:48:27修改
4
收藏
回复
举报
回复
    相关推荐