出现的问题

在使用模拟器运行自定义代码时,默认应用名称通常显示为"label",这会导致新运行的应用覆盖前一个。为解决此问题,我们需要修改应用名称。以下是具体的修改方法:

1.找到module.json5文件

1.1 找到"abilities"下面的代码块

修改"label"后面的数据为"$string:app_name"

"abilities": [
      {
        "name": "EntryAbility",
        "srcEntry": "./ets/entryability/EntryAbility.ets",
        "description": "$string:EntryAbility_desc",
        "icon": "$media:layered_image",
        "label": "$string:app_name", //修改这里
        "startWindowIcon": "$media:startIcon",
        "startWindowBackground": "$color:start_window_background",
        "exported": true,
        "skills": [
          {
            "entities": [
              "entity.system.home"
            ],
            "actions": [
              "action.system.home"
            ]
          }
        ]
      }
    ],

2.找到app.json5文件

同样是修改"label"后面的数据为"$string:app_name"

{
  "app": {
    "bundleName": "com.example.myapplication",
    "vendor": "example",
    "versionCode": 1000000,
    "versionName": "1.0.0",
    "icon": "$media:app_layered_image",
    "label": "$string:app_name" //修改这里
  }
}

3.找到string.json文件

修改"value"后面的数据为自己想要的名字即可

{
  "string": [
    {
      "name": "app_name",
      "value": "水果商城"
    }
  ]
}

显示的APP名称就变成了水果商城

{
  "string": [
    {
      "name": "app_name",
      "value": "我的APP"
    }
  ]
}

再验证一下修改string.jion里面的名称会不会改变

好的,现在确定修改成功了,下一篇介绍如何修改APP图标文章

Logo

社区规范:仅讨论OpenHarmony相关问题。

更多推荐