Intermediate: Integration of Huawei Crash service in Harmony OS


Huawei provides various services for developers to make ease of development and provides best user experience to end users. In this article, we will cover Huawei Crash Service with Java in Harmony OS.

The AppGallery Connect Crash service provides a powerful lightweight solution for app crash problems. This service helps us to minimize crash risks. Also this service integration is relatively simple and doesn’t require coding. The Crash Service provides crash reports which are easy to reference and analyze. This service helps quickly to detect, locate, and resolve app crashes (unexpected exits of apps), and have access to highly readable crash reports in real time.

After you integrate the Crash SDK into your app, it will be initialized automatically when your app is launched. When an app crash occurs, the SDK will report the crash information to HUAWEI Analytics. A readable report will be generated in 5 to 10 minutes, helping you to quickly detect, locate, and rectify the problem.

Crash Service various features

1. You can view information about a specific crash, and analyze the app and Android versions with the crash.

2. The Crash service can also detect major crashes in real time. After you enable crash notifications, App Gallery Connect can send you an email when a major crash occurs.

3. A readable report will be generated in 5 to 10 minutes, helping you to delete, locate and rectify the problem.

4. The Crash service automatically categorizes crashes, and provides indicator data of the crashes allowing you to prioritize the most important crashes.

5. You can also view information about the app, operating system, and device corresponding to a specific crash, as well as the crashed stack.

6. The last-hour crash report allows you to monitor the quality of your app in real time.

Development Overview

You need to install DevEcho studio IDE and I assume that you have prior knowledge about the Harmony OS and java.

Hardware Requirements

  • A computer (desktop or laptop) running Windows 10.
  • A Huawei phone (with the USB cable), which is used for debugging.

Software Requirements

  • Java JDK installation package.
  • DevEcho studio installed.

Follows the steps.

1. Create Harmony OS Project.

  • Open DevEcho studio.
  • Click NEW Project, select a Project Templet.
  • Select Empty Ability(Java) template and click Next as per below image.
  • Enter Project Name and Package Name and click on Finish.

2. Once you have created the project, DevEco Studio will automatically sync it with Gradle files. Find the below image after synchronization is successful.

3. Add the below maven URL in build.gradle(Project level) file under the repositories of buildscript, dependencies, for more information refer Add Configuration.

4. Add the below plugin and dependencies in build.gradle(App level)

5. Update Permission and app version in config.json file as per your requirement, otherwise retain the default values.

6. Create New > Ability, as follows.

7. Development Procedure.

Create ability and add the below code.

Create ability_main.xml layout and add the below code.

Create background_button_green_color.xml in graphic folder and add the below code.

8. To build apk and run in device, choose Build > Generate Key and CSR Build for Hap(s)\ APP(s) or Build and Run into connected device, follow the steps.


  1. Run Application on connected device, we can see below result.

2. Click on “Make Arithmetic exception” button, application will close unexpected check below result on app gallery

Tips and Tricks

  • Always use the latest version of DevEcho Studio.
  • Use Harmony Device Simulator from HVD section.
  • Do not forgot to add permission in config.json file.
  • Do not forgot to add dependencies in build.gradle.
  • Do not forgot to enable crash service.


In this article, we have learnt Crash Service in Harmony OS. Huawei Crash services makes easier to find the crashes and helps you to make crash free application also learned how to view and analyze crashes and custom crash reports and device information in which it is crashed in AppGallery Connect.

Thanks for reading the article, please do like and comment your queries or suggestions.


Harmony OS:

Crash Service Overview:



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store