OpenHarmony开发者论坛
标题:
OpenHarmonyAPI 9工程转换为API 10工程
[打印本页]
作者:
润开鸿_坚果
时间:
2023-12-21 06:25
标题:
OpenHarmonyAPI 9工程转换为API 10工程
[md]# OpenHarmonyAPI 9工程转换为API 10工程
**目前我们能够看到的是鸿蒙已经到API10,甚至今天在看OpenHarmony官网的时候,4.1beta的分支都已经有了,也就是API11马上就出来了。**
**这个时候,我们最起码要将API 9工程转换为API 10工程。然后再慢慢的迁移到未来的11上。**
**接下来我们说一下如何迁移。**
**1.将工程级build-profile.json5文件中****compileSdkVersion**和**compatibleSdkVersion**字段从**app**下迁移到当前选中的product中。当前生效的product可以通过点击编辑区域右上方![img](
https://luckly007.oss-cn-beijing ... B32214BADBC98D7.png
)图标进行查看。
```
{
"app": {
"signingConfigs": [
],
"products": [
{
"signingConfig": "default",
"name": "default",
"compileSdkVersion": 10,
"compatibleSdkVersion": 10,
"targetSdkVersion": 10,
"runtimeOS": "OpenHarmony"
}
]
},
"modules": [
{
"srcPath": "./entry",
"name": "entry",
"targets": [
{
"name": "default",
"applyToProducts": [
"default"
]
}
]
},
{
"srcPath": "./common",
"name": "common",
"targets": [
{
"name": "default",
"applyToProducts": [
"default"
]
}
]
}
]
}
```
**2.请将****compileSdkVersion**和**compatibleSdkVersion**改为10。同时在当前product下配置targetSdkVersion(若需要)和runtimeOS。
```
"app": {
"signingConfigs": [],
"products": [
{
"name": "default",
"signingConfig": "default",
"compileSdkVersion": 10, //OpenHarmony/服务编译时的版本
"compatibleSdkVersion":10, //指定OpenHarmony应用/服务兼容的最低版本。
"targetSdkVersion": 10, //指定OpenHarmony应用/服务目标版本。若没有设置,默认为compatibleSdkVersion
"runtimeOS": "OpenHarmony" //指定为OpenHarmony
}
],
```
**3.将其他各模块级别的build-profile.json5文件中target字段下的runtimeOS配置删除。**
![image-20231220224149780](
https://luckly007.oss-cn-beijing ... 231220224149780.png
)
![image-20231220224213419](
https://luckly007.oss-cn-beijing ... 231220224213419.png
)
**4.单击Sync Now完成同步。**
**这样我们就完成迁移了。**
![image-20231220224433537](
https://luckly007.oss-cn-beijing ... 231220224433537.png
)
**是不是很简单。**
[/md]
欢迎光临 OpenHarmony开发者论坛 (https://forums.openharmony.cn/)
Powered by Discuz! X3.5