DEV Community

HarmonyOS
HarmonyOS

Posted on

Practical Guide: Detailed Tutorial for Publishing HarmonyOS Apps

Read the original article:Practical Guide: Detailed Tutorial for Publishing HarmonyOS Apps

Contents

  • Preface
  • Preparations
  • Step 1: Generate P12 file.
  • Step 2: Generate CSR file.
  • Step 3: Generate CER file.
  • Step 4: Generate P7B file.
  • Step 5: IDE configuration.
  • Summary

Preface

During the development process, many developers encounter multiple obstacles when publishing apps. Faced with various certificate formats such as .p12, .csr, .cer, .p7b, as well as the app packaging process, many developers feel completely lost and do not know where to start.
This article will provide a detailed explanation of these seemingly tedious yet crucial steps to help you successfully complete the full app publishing process. If you have ever struggled with these issues, please continue reading, and let us uncover the mysteries of app publishing together. Let us get started.

Preparations

Before getting started, please ensure you have:

  1. Installed the latest version of DevEco Studio.
  2. Completed app development and testing.
  3. Registered a Huawei developer account and logged in to the AGC platform.

Step 1: Generate P12 file.

  1. Open DevEco Studio and load the project you want to publish.
  2. Locate the Build button at the top of the IDE, as shown below:

干货分享:鸿蒙应用上架详细教程-鸿蒙开发者社区

3.In the Build button dropdown menu, find and click Generate Private Key and Certificate Request File:

干货分享:鸿蒙应用上架详细教程-鸿蒙开发者社区

4.In the pop-up, pay attention to the following points:

  • Project alias:Make sure to remember this alias
  • Password settings:It is recommended to use a unified password for easy recall
  • File storage:It is recommended to create a separate folder for each app to store certificate files.

干货分享:鸿蒙应用上架详细教程-鸿蒙开发者社区

5.Click the New button, select the file storage location, and set the password. Then click OK.

Tip: Information such as alias, developer name, and organization only needs to be memorable; strict rules do not apply.

干货分享:鸿蒙应用上架详细教程-鸿蒙开发者社区

6.After filling in the information, click Next:

干货分享:鸿蒙应用上架详细教程-鸿蒙开发者社区

7.Upon completion, the .p12 file will be generated in your specified folder:
干货分享:鸿蒙应用上架详细教程-鸿蒙开发者社区

Step 2: Generate CSR file.

  1. After clicking Next in Step 1, you will see the following interface:

干货分享:鸿蒙应用上架详细教程-鸿蒙开发者社区

2.In the pop-up, select the storage path for the CSR file, then click Finish:

干货分享:鸿蒙应用上架详细教程-鸿蒙开发者社区

Note: File names can be defined freely, but meaningful names are recommended for easier identification.

3.After completing this step, you will have successfully generated the .p12 and .csr files:

干货分享:鸿蒙应用上架详细教程-鸿蒙开发者社区

4.Next, log in to the AGC platform for subsequent operations.

Step 3: Generate CER file.

  1. In the AGC platform, select Certificates, APP ID, and Profile from the left navigation bar, then click Add Certificate:

干货分享:鸿蒙应用上架详细教程-鸿蒙开发者社区

2.Fill in the required information in the pop-up and upload the CSR file generated in Step 2:

干货分享:鸿蒙应用上架详细教程-鸿蒙开发者社区

3.After creation, click Download to save the certificate file locally:

干货分享:鸿蒙应用上架详细教程-鸿蒙开发者社区

Tip: It is recommended to save the downloaded certificate in the same folder as the previously generated files for easier management.

Step 4: Generate P7B file.

  1. In the AGC platform, go to Profile from the left navigation bar. Click Add on the page:

干货分享:鸿蒙应用上架详细教程-鸿蒙开发者社区

2.Fill in the following information in the pop-up:

  • App name:Select the app you want to publish from the dropdown list
  • Profile name:Customize a recognizable name
  • Select certificate:Choose the certificate generated in Step 3
  • Request permissions:Select permissions according to your app's actual needs

3.After filling in, click Add:

干货分享:鸿蒙应用上架详细教程-鸿蒙开发者社区

4.Once added, click Download to save the Profile file locally:

干货分享:鸿蒙应用上架详细教程-鸿蒙开发者社区

Important: Follow the principle of least privilege when requesting permissions. Only request permissions necessary for the app to avoid rejection during review.

Step 5: IDE configuration.

  1. After completing the previous four steps, you now have all the required certificate files. Next, configure them in the IDE.
  2. In DevEco Studio, go to File > Project Structure.
  3. In the pop-up, select the Signing Config tab to configure the corresponding certificate files:

干货分享:鸿蒙应用上架详细教程-鸿蒙开发者社区

4.In the configuration interface:

  • Select the previously generated .p12 file.
  • Enter the password set when creating the .p12 file.
  • Select the downloaded Profile file.
  • Ensure all paths are correct.

5.After the configuration, click OK to save the settings.

Step 6: Package the app.

  1. After certificate configuration, select Build > Compile Hap(s)/APP(s) > Compile APP(s):

干货分享:鸿蒙应用上架详细教程-鸿蒙开发者社区

2.After compilation, a build folder will be generated in your project directory.

3.In the build folder, locate the installation package in xxxxx-signed.app format:

干货分享:鸿蒙应用上架详细教程-鸿蒙开发者社区

4.Upload this installation package to the corresponding version on the AGC platform to complete the app publishing preparation.

Tip: Before uploading, ensure the app has undergone sufficient testing, including functional, compatibility, and performance testing.

Summary

Through this tutorial, we have completed all preparations for publishing a HarmonyOS app, including:

  1. Certificate generation:Successfully created .p12 and .csr files.
  2. AGC platform operations:Generated .cer certificates and Profile files.
  3. IDE configuration:Completed signing configuration in DevEco Studio.
  4. App packaging:Generated a signed app installation package. Although these steps may seem cumbersome, each one is critical to ensuring your app can be successfully published on the Huawei AppGallery. Wishing you a smooth app publishing experience. Class dismissed.

Written by Full-stack Developer Ruocheng

Top comments (0)