1.问题
鸿蒙真机运行报错Failure[INSTALL_PARSE_FAILED_USESDK_ERROR],如何解决呢?
compileSdkVersion and releaseType of the app do not match the apiVersion and releaseType on the device.
2.原因
编译sdk版本高于真机SDK版本。先确定真机SDK版本
2.1 查看设备版本信息
使用工具链为:/Users/用户名/Library/Huawei/Sdk/hmscore/3.1.0/toolchains
目录
添加环境变量
export HDC_HOME=/Users/ksnowlv/Library/Huawei/Sdk/hmscore/3.1.0/toolchains
先使用hdc list targets
查看设备,再查看设备apiversion
与releasetype
1
2
3
4
5
6
7
8
|
ksnowlv@MacBook-Pro-3 Hello_hoos_world % hdc list targets
GBG5T19710007532 device
emulator-5554 device
ksnowlv@MacBook-Pro-3 Hello_hoos_world % hdc -t GBG5T19710007532 shell getprop hw_sc.build.os.apiversion
6
ksnowlv@MacBook-Pro-3 Hello_hoos_world % hdc -t GBG5T19710007532 shell getprop hw_sc.build.os.releasetype
Release
|
2.解决方案
下载api版本为6的SDK版本
修改项目根目录下的build-profile.json5
文件中的compileSdkVersion
和compatibleSdkVersion
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
{
"app": {
"signingConfigs": [
{
"name": "default",
"type": "HarmonyOS",
"material": {
"certpath": "/Users/ksnowlv/.ohos/config/auto_debug_Hello_hoos_world_com.example.hello_hoos_world_420086000303510047.cer",
"storePassword": "0000001BD2A2C2CD5BAB52C92ADB8CA3295B04BF0FCE4CE894A05DA06E0308B50980614A9526DA881CA8FB",
"keyAlias": "debugKey",
"keyPassword": "0000001BE1F52DE9FC961251900696A105654889C2594855940377CC0A21F378BF43D503B314BFC6590CC1",
"profile": "/Users/ksnowlv/.ohos/config/auto_debug_Hello_hoos_world_com.example.hello_hoos_world_420086000303510047.p7b",
"signAlg": "SHA256withECDSA",
"storeFile": "/Users/ksnowlv/.ohos/config/auto_debug_Hello_hoos_world_com.example.hello_hoos_world_420086000303510047.p12"
}
}
],
"compileSdkVersion": 9,
"compatibleSdkVersion": 9,
"products": [
{
"name": "default",
"signingConfig": "default",
}
]
},
"modules": [
{
"name": "entry",
"srcPath": "./entry",
"targets": [
{
"name": "default",
"applyToProducts": [
"default"
]
}
]
}
]
}
|
重新编译运行即可。
文章作者
梵梵爸
上次更新
2024-05-10
许可协议
原创文章,如需转载请注明文章作者和出处。谢谢