编译arkts项目提示版本不匹配问题
编译arkts项目提示版本不匹配问题:compatibleSdkVersion and releaseType of the app do not match the apiVersion and releaseType on the device.
进入devEcostudio安装目录:D:\Huawei\DevEcoStudio\sdk\default\openharmony\toolchains,执行下列命令:
hdc shell param get const.ohos.apiversion
当前设备的api版本为:17
而项目目录下的buil-profile.json5中设置为:18 如下
"compatibleSdkVersion": "5.1.0(18)",


其中安装的虚拟机api版本如下:正在运行的模拟器huawei_2in1的api版本为:17 和项目api版本18不一致造成的。

当通过huawei_phone api18调试程序时可以正常运行,如下


所以,创建的项目要使用的api版本要和虚拟机的版本保持一致,不会出现该问题
目前只有huawei_phone有18等多个版本,而huawei_2in1及其他虚拟机只有17版本,
如果使用huawei_2in1需要修改项目下的build-profile.json5文件中的
"targetSdkVersion": "5.1.0(18)",
"compatibleSdkVersion": "5.0.5(17)",
改为:
"targetSdkVersion": "5.0.5(17)",
"compatibleSdkVersion": "5.0.5(17)",
因为默认创建17版本项目默认为:
"targetSdkVersion": "5.1.0(18)",
"compatibleSdkVersion": "5.0.5(17)",



安装HAP时提示“compatibleSdkVersion and releaseType of the app do not match the apiVersion and releaseType on the device.”
问题现象
在启动调试或运行应用/服务时,安装HAP出现错误,提示“compatibleSdkVersion and releaseType of the app do not match the apiVersion and releaseType on the device.”错误信息。

解决措施
出现该问题是因为当前工程的兼容的最低版本高于设备镜像版本。
使用命令hdc shell param get const.ohos.apiversion查询当前设备的api版本,对比看下工程级build-profile.json5配置的compatibleSdkVersion字段api版本。可以使用以下解决办法:
方法一:请升级设备镜像版本以匹配当前工程版本,请在设备的系统设置界面去升级设备系统。
方法二:降低工程的api版本,修改工程级build-profile.json5配置的compatibleSdkVersion字段api版本兼容设备的api版本。
浙公网安备 33010602011771号