【错误记录】HarmonyOS 运行报错 ( Failure INSTALL_PARSE_FAILED_USESDK_ERROR )

文章目录

一、报错信息


在 DevEco Studio 中 , 使用 远程设备 , 向 P40

FailureINSTALL_PARSE_FAILED_USESDK_ERROR

compileSdkVersion and releaseType of the app do not match the apiVersion and releaseType on the device.

二、问题分析


报错信息翻译后内容为 : 应用的 compileSdkVersion 和 releaseType 与设备上的 apiVersion 和 releaseType 不匹配 ;

当前使用的 P40 远程设备 , 使用的是 API 8 版本的 SDK ;

在 根目录下的 build-profile.json5 中配置的 编译版本 ,

  • compileSdkVersion 配置的 编译版本是 API 9 ;
  • compatibleSdkVersion 配置的 最低兼容的版本是 API 9 , 该配置使得应用不能再低于 API 9 的设备中运行 ;

build-profile.json5 完整配置信息如下 :

json 复制代码
{
  "app": {
    "signingConfigs": [],
    "compileSdkVersion": 9,
    "compatibleSdkVersion": 9,
    "products": [
      {
        "name": "default",
        "signingConfig": "default",
      }
    ],
    "buildModeSet": [
      {
        "name": "debug",
      },
      {
        "name": "release"
      }
    ]
  },
  "modules": [
    {
      "name": "entry",
      "srcPath": "./entry",
      "targets": [
        {
          "name": "default",
          "applyToProducts": [
            "default"
          ]
        }
      ]
    }
  ]
}

如果 只将 "compatibleSdkVersion": 设置改为 8 , 会报如下错误 :

Apps of API version 9 cannot run on devices of API version 8 or earlier. Set compatibleSdkVersion to 9 or a larger value in the project-level build-profile.json5 file.

API 版本 9 的应用程序无法在 API 版本 8 或更早的设备上运行 ,

在 项目级构建配置文件 build-profile.json5 file 中 将 compatibleSdkVersion 设置为 9 或更大的值 ;

这里需要同时将 compileSdkVersion 和 compatibleSdkVersion 版本号都改为 8 ;

javascript 复制代码
    "compileSdkVersion": 8,
    "compatibleSdkVersion": 8,

此时 点击 Sync Now 进行同步 , 会报如下错误 ;

Cause:

1.The @ohos/hvigor version () is not within the expected range 3.x.x (3.x.x >= 3.0.9).

2.The @ohos/hvigor-ohos-plugin version () is not within the expected range 3.x.x (3.x.x >= 3.0.9).

Solution: Change the values of @ohos/hvigor to 3.0.9 and @ohos/hvigor-ohos-plugin to 3.0.9, while updating the command line script hvigor-wrapper.js that matches hvigor, which will auto-install the respective versions of the tools. Then sync the project again.

翻译后 :

原因:

1.@ohos/hvigor version () 不在预期的 3.x.x (3.x.x >= 3.0.9) 范围内 ;

2.@ohos/hvigor-ohos-plugin version () 不在预期的 3.x.x (3.x.x >= 3.0.9) 范围内 ;

解决方法:将 @ohos/hvigor 的值改为 3.0.9 并且 将 @ohos/hvigor-ohos-plugin 的值改为3.0.9 , 同时更新与 hvigor 匹配的命令行脚本hvigor-wrapper.js , 该脚本将自动安装相应版本的工具 , 然后再次同步项目 ;

三、解决方案


由于该项目创建时 , 直接创建的 API 9 的项目 , 所有的配置都基于 API 9 进行 配置的 , 这里重新创建一个 API 8 的项目 ;

选择项目的 SDK 版本号为 API 8 , 然后点击 Finish 完成创建 ;

相关推荐
2501_919749033 小时前
华为鸿蒙免费PDF工具—小羊免费PDF
华为·pdf·harmonyos·鸿蒙
贾伟康4 小时前
【口算王|10】HarmonyOS ArkTS 语音报题实战:协调朗读、作答和页面生命周期
生命周期·harmonyos·arkts·语音交互·texttospeech
贾伟康6 小时前
【口算王|08】HarmonyOS ArkTS 分类训练实战:让年级与运算分类参数保持一致
harmonyos·arkts·数据建模·路由参数·分类训练
小飞象—木兮6 小时前
经营复盘指南:核心概念、7 个核心指标、华为复盘管理标杆实践、案例·
华为
光锥智能6 小时前
华为新麒麟芯片、鸿蒙7问世,手机底层竞赛升级
华为·智能手机·harmonyos
贾伟康7 小时前
【口算王|09】HarmonyOS ArkTS 学习统计实战:计算连续训练和正确率趋势
harmonyos·arkts·数据可视化·preferences·学习统计
lqj_本人7 小时前
Flutter 鸿蒙实战:用 wakelock_plus 三方库给阅读页加上屏幕常亮
flutter·华为·harmonyos
aqi0017 小时前
鸿蒙版本的JSBridge兼容与安卓配套的H5啦
android·华为·harmonyos·鸿蒙·移动应用
熊猫钓鱼>_>18 小时前
Flutter app_settings 鸿蒙适配实战:Intent 体系到 Want 的跨越
flutter·华为·harmonyos·openharmony·intent·want
贾伟康21 小时前
【句匠|20】HarmonyOS ArkTS AppGallery 发布复查实战:核对包名、版本、设备、素材和离线声明
harmonyos·arkts·应用上架·appgallery·发布审核