HarmonyOS鸿蒙Next中flutter转项目自动签名报错

HarmonyOS鸿蒙Next中flutter转项目自动签名报错 【问题描述】:flutter转鸿蒙项目自动签名报错The bundle name contains 7 to 128 characters, including only letters, digits, and underscores ( ). it must start with a letter and contain at least three seaments separated by periods (.), each of the segments ending with a digit or letter.

【问题现象】:Flutter ohos包 自动签名报错The bundle name contains 7 to 128 characters, including only letters, digits, and underscores ( ). it must start with a letter and contain at least three seaments separated by periods (.), each of the segments ending with a digit or letter.

【版本信息】:flutter ohos HarmonyOS NEXT

【复现代码】:无


更多关于HarmonyOS鸿蒙Next中flutter转项目自动签名报错的实战教程也可以访问 https://www.itying.com/category-92-b0.html

4 回复

执行步骤:
1.重新执行编译操作 flutter build hap --debug / release
2.使用ide打开ohos包
检查包名规范是否合规
如有更改文件 在更改过后同步项目
cke_214.png
3.最后执行签名操作

更多关于HarmonyOS鸿蒙Next中flutter转项目自动签名报错的实战系列教程也可以访问 https://www.itying.com/category-92-b0.html


包名是什么,

在HarmonyOS Next中,Flutter项目自动签名报错通常是由于签名配置问题导致。请检查项目中的build-profile.json文件,确保签名配置正确。同时,确认signingConfigs中的storeFile路径和密码准确无误。若问题持续,可尝试清理并重新构建项目。

这个报错明确指出你的应用包名(bundle name)不符合HarmonyOS Next的规范。错误信息要求包名必须满足以下所有条件:

  1. 长度:7到128个字符。
  2. 字符:只能包含字母、数字和下划线(_)。
  3. 开头:必须以字母开头。
  4. 结构:必须包含至少三个由点(.)分隔的段(segment)。
  5. 段结尾:每个段(包括最后一段)的最后一个字符必须是字母或数字。

根本原因:在将Flutter项目转换为鸿蒙项目时,自动生成的或你配置的包名(通常在 module.json5 文件的 bundleName 字段中)不满足上述第4条或第5条要求。

解决方案: 你需要检查并修改项目的包名。关键文件是 entry/src/main/module.json5 (或类似路径下的module.json5文件)。

  1. 打开 entry/src/main/module.json5 文件。
  2. 找到 "bundleName" 字段。
  3. 将其值修改为一个符合规则的包名。

正确包名示例

  • com.example.myapp (经典三段式,每段以字母结尾)
  • com.company.project123 (第三段以数字结尾,符合要求)
  • org.hello.world_test (包含下划线,且每段以字母或数字结尾)

错误包名示例

  • com.example (只有两段,不满足“至少三段”的要求)
  • com.example. (最后一段为空,不以字母或数字结尾)
  • com.example.my-app (包含连字符“-”,非法字符)
  • 123.abc.def (第一段以数字开头,不符合“以字母开头”)

修改并保存 module.json5 文件后,重新执行签名操作即可。

回到顶部