.鸿蒙NEXT编译错误 The version "xxx" is invalid, reached retry limit or non retryable error encountered.
说明
在test_demo工程下新建libtest模块,编译产物的 libtest.har,放在test_demo/ibs中运行;
错误现象
har包的版本号定义
libtest/oh-package.json5:
{
"name": "libtest",
"version": "1.0.20241023.1707",
"description": "Please describe the basic information.",
"main": "Index.ets",
"author": "",
"license": "Apache-2.0",
"dependencies": {
"libtest.so": "file:./src/main/cpp/types/libtest"
}
}
假如版本定义: "1.0.20241023.1707"
"\"C:\Program Files\Huawei\DevEco Studio\tools\ohpm\bin\ohpm.bat\"" install --all --registry https://ohpm.openharmony.cn/ohpm/ --strict_ssl true
ohpm ERROR: Found exception: Error: The version "1.0.20241023.1707" of dependency "test@D:\ohos\sourcecode\test_demo_v1.0.0.har" is invalid, reached retry limit or non retryable error encountered.
ohpm ERROR: ERUNNING execute tasks failed, Error: The version "1.0.20241023.1707" of dependency "test@D:\ohos\sourcecode\test_demo_v1.0.0.har" is invalid
ohpm ERROR: Install failed, detail: Error: The version "1.0.20241023.1707" of dependency "test@D:\ohos\sourcecode\test_demo_v1.0.0.har" is invalid
Process finished with exit code 1
问题原因
问题描述的字面意思可以知道是版本号超限了,可能是hvigor编译框架的限制。简单的说就是版本号中间的点"."超限了(也许后期华为会修改问题)。
解决办法
修改版本号,把点"."减少
libtest/oh-package.json5:
{
"name": "libtest",
"version": "1.0.202410231707",
"description": "Please describe the basic information.",
"main": "Index.ets",
"author": "",
"license": "Apache-2.0",
"dependencies": {
"libtest.so": "file:./src/main/cpp/types/libtest"
}
}
如果此时编译还是提示上面的问题,是之前的 test_demo/ibs中的libtest.har错误,删除test_demo/ibs中/libtest.har,再次编译即可得到新的libtest.har。
新的libtest.har,用DevEco打开看,har包里面BuildProfile.ets如下
/**
* Use these variables when you tailor your ArkTS code. They must be of the const type.
*/
export const HAR_VERSION = '1.0.202410231707';
export const BUILD_MODE_NAME = 'release';
export const DEBUG = false;
export const TARGET_NAME = 'default';
/**
* BuildProfile Class is used only for compatibility purposes.
*/
export default class BuildProfile {
static readonly HAR_VERSION = HAR_VERSION;
static readonly BUILD_MODE_NAME = BUILD_MODE_NAME;
static readonly DEBUG = DEBUG;
static readonly TARGET_NAME = TARGET_NAME;
}
把新的libtest.har拷贝到test_demo/libs中,再次编译,即可解决问题。
有其他问题请在下面讨论。