签署 Android 软件包
要发布应用程序,必须使用由证书和相应私钥组成并以别名标识的公私 密钥 对对应用程序进行签名。密钥对用于验证应用程序的未来版本确实是由您创建的。
警告 请将密钥对妥善保管并备份,因为如果丢失了密钥对,就无法更新应用程序。
您可以使用Qt Creator 生成密钥存储和自签名证书。生成的证书具有 X.509 v3 数字证书的结构。它包含证书的版本、序列号和有效期、用于加密数据的算法 ID、颁发证书的机构以及证书的主体(所有者)等信息。如果是自签证书,证书的签发者和所有者是相同的。此外,证书还包含用于签署证书的算法以及证书签名的信息。
密码保护密钥存储。此外,还可以用密码保护每个别名。
签署 Android 应用程序时,必须选择有证书的密钥库,并从密钥库中选择证书别名。签名过程会将别名的公钥(证书)嵌入 APK。
创建密钥库和证书
创建密钥库和自签名证书:
- 转至Projects >Build Settings >Build Android APK 并选择Details 。

- 在Keystore 字段中,选择Create ,在Create a Keystore and a Certificate 对话框中创建一个有一个密钥对的新密钥存储:

- 在Keystore 组中,输入密码以保护密钥存储。
- 在Certificate 组中,指定证书的密钥大小和有效期。可以指定单独的密码来保护密钥对,也可以使用密钥存储密码。
- 在Certificate Distinguished Names 组中,输入有关你本人和你的公司或组织的信息,以确定密钥对的签发人和所有者。
- 选择Save 。
- 在Keystore File Name 对话框中,输入密钥存储的名称并选择位置。
- 在Keystore 对话框中,输入密钥库密码,以便在密钥库中创建配对密钥。
签署软件包
使用密钥对签署 Android 软件包:
- 转到Projects >Build Settings >Build Android APK 并选择Details 。
- 在Keystore 字段中,选择Choose 以选择现有密钥库。
- 在Certificate alias 字段中,从密钥库的密钥对列表中选择一个别名。
- 选择Sign package 以使用别名签署 Android 软件包。
另请参阅 如何:为 Android 开发和为 Android 开发。
Copyright © The Qt Company Ltd. and other contributors. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.