Beginner: Huawei Crash an Analytics Service in Unity Game Development


In this article, we will cover Integration of Huawei Crash Kit in Unity Project using Official Plugin (Huawei HMS Core App Services). A crash is basically an unhandled exception which makes the system to kill the application process that caused the crash. Huawei Crash Service provides a powerful lightweight solution to app crash problems. In this service, you can quickly detect, locate, and resolve app crashes (unexpected exits of apps), and have access to highly readable crash reports in real time, without the need to write any code.

After you integrate the Crash SDK into your app, it will be automatically initialized 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 about 5 to 10 minutes, helping you quickly detect, locate, and rectify the problem.

Development Overview

You need to install Unity software and I assume that you have prior knowledge about the unity and C#.

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.
  • Unity software installed.
  • Visual Studio/Code installed.
  • HMS Core (APK) 4.X or later.

Follows the steps.

1. Create Unity Project.

  • Open Unity Hub.
  • Click NEW, select 3D, Project Name 3D, and Location.
  • Click CREATE, as follows:

2. Click Asset Store, search Huawei HMS Core App Services and click Import, as follows.

3. Once import is successful, verify directory in Assets > Huawei HMS Core App Services path, as follows.

4. Choose Edit > Project Settings > Player and edit the required options in Publishing Settings, as follows.

5. Generate a SHA-256 certificate fingerprint.

To generating SHA-256 certificate fingerprint use below command.

6. Download agconnect-services.json and copy and paste to Assets > Plugins > Android, as follows.

7. Choose Project Settings > Player and update package name.

8. Open LauncherTemplate.gradle and add below line.

9. open AndroidManifest file and add below permissions.

10. Open “baseProjectTemplate.gradle” and add lines, as follows.

11. Open “mainTemplate.gradle” and add lines like shown below.

12. Create Scripts folder and create a class.

13. Follow the steps, as shown in image:

a. Assign Ads script to Canvas.

b. Select Button and add onclick event

c. Assign button to button handler.

14. Onclick Button Handler you find your script CrashManager (As per your script name) and attach method as per below screen shot.

15. To build apk and run in device, choose File > Build Settings > Build for apk or Build and Run for run on connected device.


  1. Click on Report a Crash you can see App crashed now you can see report in AppGallery Connect. You can quickly detect,locate, and resolve app crashes (unexpected exits of apps) as per below screens.

2. Click on Custom value button you can check custom value on AppGallery Connect as per below screen.

Tips and Tricks

  • Always use the latest version of the library.
  • Add agconnect-services.json file without fail.
  • Add SHA-256 fingerprint without fail.
  • Make sure dependencies added in build files.
  • Make sure you have enable debug mode.


We have learnt integration of Huawei Crash Service into Unity Game development. 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 in AppGallery Connect.

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


HMS Crash Kit

HMS Analytics Kit