Skip to content

应用签名与发布 ​

鸿蒙应用签名流程、发布渠道、上架审核。


1. 应用签名 ​

1.1 签名类型 ​

类型用途有效期
调试签名开发调试短期(1 年)
发布签名正式发布长期(25 年)

1.2 生成密钥对 ​

bash
# 使用 DevEco Studio 生成
# 或使用命令行工具

# 生成私钥
hdc shell generatekey -alias release -keyalg RSA -keysize 2048 -validity 25000

# 生成证书
hdc shell generatecert -alias release -storepass <password> -keypass <password>

1.3 配置签名 ​

json5
// build-profile.json5
{
    "app": {
        "signingConfigs": [
            {
                "name": "debug",
                "type": "HarmonyOS",
                "material": {
                    "certpath": "/path/to/debug.cer",
                    "storePassword": "0000001A...",
                    "keyAlias": "debugKey",
                    "keyPassword": "0000001A..."
                }
            },
            {
                "name": "release",
                "type": "HarmonyOS",
                "material": {
                    "certpath": "/path/to/release.cer",
                    "storePassword": "<password>",
                    "keyAlias": "releaseKey",
                    "keyPassword": "<password>"
                }
            }
        ],
        "products": [
            {
                "name": "default",
                "signingConfig": "debug"
            },
            {
                "name": "release",
                "signingConfig": "release"
            }
        ]
    }
}

2. 应用打包 ​

2.1 打包流程 ​

开发完成
    ↓
配置签名
    ↓
构建 Release 版本
    ↓
生成 .app 或 .hap 文件
    ↓
上传应用市场

2.2 打包命令 ​

bash
# 使用 hvigor 构建
hvigorw assembleRelease

# 输出位置
# entry/build/outputs/entry-default-release.apk

3. 应用发布 ​

3.1 发布渠道 ​

渠道说明
华为应用市场官方应用商店
其他应用市场第三方商店
企业分发企业内部测试
官网下载官网提供下载链接

3.2 上架流程 ​

准备材料
├─ 应用安装包(.app)
├─ 应用图标
├─ 应用截图
├─ 应用描述
├─ 隐私政策
└─ 测试账号(如需)
    ↓
提交审核
    ↓
审核通过(1-3 个工作日)
    ↓
上架发布

4. 版本管理 ​

4.1 版本号配置 ​

json5
// build-profile.json5
{
    "app": {
        "products": [
            {
                "name": "release",
                "versionCode": 10001,  // 版本号(整数递增)
                "versionName": "1.0.1"  // 版本名称
            }
        ]
    }
}

4.2 版本更新策略 ​

版本更新:
├─ 强制更新(重大 bug/安全漏洞)
├─ 推荐更新(新功能)
└─ 可选更新(小优化)

5. 面试高频考点 ​

Q1: 应用签名流程? ​

回答:生成密钥对 → 配置 build-profile.json5 → 构建 Release 版本 → 签名后的 .app 文件。

Q2: 版本号如何管理? ​

回答:versionCode 整数递增(内部版本),versionName 语义化版本(用户可见)。


🐱 小猫提示:应用签名记住 "调试/发布签名、build-profile 配置、versionCode 递增、应用市场上架"。