同步操作将从 OpenHarmony/docs 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
Before running and debugging the OpenHarmony app on a real device, you need to sign the app. This section describes how to configure the signature of an OpenHarmony app. Operation instructions are the same in HUAWEI DevEco Studio User Guide except this section. For details, see HUAWEI DevEco Studio User Guide. See the following figure for the process of configuring app signature information.
OpenHarmony uses digital certificates (.cer) and Profile files (.p7b) to ensure app integrity. Before applying for these files, you need to generate a key store (.p12) and a certificate signing request (.csr). You can do so in DevEco Studio or a command-line tool. For details, see Generating a Key Store and CSR.
Use the CSR generated in Generating a Key Store and CSR to generate the digital certificate required for app signing. The method is as follows:
Go to the Sdk\toolchains\lib directory where the OpenHarmony SDK is saved (see Configuring the OpenHarmony SDK for details) in the DevEco Studio installation directory, and run the following command in the CLI. If the keytool command cannot be executed, add the JDK environment variables to the system environment variables. You only need to modify the input and output to quickly generate a certificate. That is, modify -infile to specify the path of the CSR and -outfile to specify the name and path of the output certificate.
keytool -gencert -alias "OpenHarmony Application CA" -infile myApplication_ohos.csr -outfile myApplication_ohos.cer -keystore OpenHarmony.p12 -sigalg SHA384withECDSA -storepass 123456 -ext KeyUsage:"critical=digitalSignature" -validity 3650 -rfc
Refer to the following descriptions about the parameters in the command:
The profile contains the package name of the OpenHarmony app, digital certificate information, certificate permissions that can be applied for by the app, and devices that support app debugging (the device list will be empty if the app type is Release). Each app package must contain a profile file.
Go to the Sdk\toolchains\lib directory, open the command-line tool, and run the following command.
java -jar provisionsigtool.jar sign --in UnsgnedReleasedProfileTemplate.json --out myApplication_ohos_Provision.p7b --keystore OpenHarmony.p12 --storepass 123456 --alias "OpenHarmony Application Profile Release" --sigAlg SHA256withECDSA --cert OpenHarmonyProfileRelease.pem --validity 365 --developer-id ohosdeveloper --bundle-name package name --permission restricted permission name (optional) --permission restricted permission name (optional) --distribution-certificate myApplication_ohos.cer
Refer to the following descriptions about the parameters in the command:
Before debugging on a real device, use the private key file (.p12), certificate file (.cer), and profile file (.p7b) to sign the target module.
Go to File > Project Structure > Project > Signing Configs > debug, deselect Automatically generate signing, and configure the signature information of the specified module.
Click OK to save your configurations. Then you can view the signature configuration information in build.gradle of the project.
By default, the type of a HAP package compiled using DevEco Studio is set to debug. For a release type, click the OhosBuild Variants tab in the lower left corner of the project and set the type to release. For details about how to compile and build the HAP, see HUAWEI DevEco Studio User Guide.
After the compilation is complete, you can obtain the HAP package of your OpenHarmony app from the build directory of the project.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。