Crash (AGC)
Crash Service Introduction
Crash Service of AppGallery Connect is a lightweight crash analysis service, in which Huawei provides a Crash SDK that can be quickly integrated into your app, without the need for coding.
Functions
The Crash service provides real-time reports for the last 24 hour, allowing you to monitor the quality of your app in real time.
In addition, the Crash service automatically categorizes crashes, and provides indicator data of the crashes, allowing you to prioritize the most important crashes. You can view information about a specific crash, and analyze the app and Android versions with the crash. You can also view information about the app, operating system, and device corresponding to a specific crash, as well as the crashed stack. All the information is enormously helpful in locating and resolving crashes.
The Crash service can also detect major crashes in real time. After you enable crash notifications, AppGallery Connect can send you an email when a major crash occurs.
How Can I Use the Crash Service
No. |
Step |
Description |
|---|---|---|
| 1 | Getting started | Before using the Crash service, you will need to integrate the Crash SDK into your app. For details, please refer to Android丨iOS. |
| 2 | Testing the Crash service | In the test phase, you can intentionally trigger a crash and check whether the Crash SDK integrated into your app can report crash data. For details, please refer to Android丨iOS. |
| 3 | Analyzing a crash | After the Crash SDK is integrated into your app, it will automatically report crash data to AppGallery Connect when your app crashes. You can analyze the cause of the crash, based on the reported data. This document uses an intentionally triggered crash to demonstrate the detailed crash locating procedure. For details, please refer to Android丨iOS. |
How to integrate the AppGallery Connect SDK to your Unity Project?
You must integrate the AppGallery Connect SDK and plug-in before integrating the Crash SDK into your app. For details, please refer to AppGallery Connect Service Getting Started.
Setting up unity Custom Android manifest and gradle
- Switch platform to android. In player setting
Enable custom manifest and gradle in player setting. The following is in unity 2019.4
The android struct is after unity 2019.3, manifest and gradle are separated into multiple files.Edit -> Project Settings -> Player -> Android(icon) -> other settings -> Identification -> Package Name
The package name is the package name of app in huawei project.
Enabling the Crash Service
First, you need to create a project and app according to the document.
- Sign in to AppGallery Connect and select My projects.
- Config the json file
Note:
Copy the agconnect-services.json file to the Assets/Plugins/Android folder.

Enabling HUAWEI Analytics Kit
The Crash service uses capabilities of HUAWEI Analytics Kit to report crash events. Therefore, you need to enable HUAWEI Analytics Kit before integrating the Crash SDK. For details, please refer to Service Enabling.
Integrating Crash Kit
1).Enable and add configurations to project gradle
Edit -> Project Settings -> Player -> Android(icon) -> Publishing Settings -> Build
enable Custom Base Gradle Template and add the configuration to the Maven repository which path is ‘Assets-> Plugins -> Android -> baseProjectTmeplate.gradle‘
You will get baseProjectTmeplate.gradle. If unity version is 2019.2 or before, you should add implement and other configuration on MainGradleTemplate.And the repository is:
allprojects {
buildscript {
repositories {
...
maven { url 'https://developer.huawei.com/repo/' }
...
}
dependencies{
classpath 'com.huawei.agconnect:agcp:1.4.2.300'
… }
}
...
repositories {
...
maven { url 'https://developer.huawei.com/repo/' }
...
}
}
2).Enable and add configurations to app gradle
Edit -> Project Settings -> Player -> Android(icon) -> Publishing Settings -> Build
enable Custom Launcher Gradle Templateand add build dependencies in launcherTemplate.gradle and the path is ‘Assets-> Plugins -> Android -> LauncherTmeplate.gradle‘
If unity version is 2019.2 or before, you should add implement and other configuration on MainGradleTemplate. To add applinking Kit.
apply plugin: 'com.huawei.agconnect'
dependencies {
…
implementation 'com.huawei.hms:hianalytics:5.0.5.300'
implementation 'com.huawei.agconnect:agconnect-crash:1.4.1.300'
implementation 'com.huawei.agconnect:agconnect-core:1.4.2.300'
...
}
3).Setting up a scene
3-1.Open a scene:

3-2.Right click and select UI and then you can choose a button:

3-3.Add component to the button and develop a script:


3-4.Edit the script:
Double click the script file,and u will open it in VS code

3-5.Defines the interface
Create a function above
void Start()
{
}
// Update is called once per frame
void Update()
{
}
public void aaronButtonTest()
{
AGConnectCrash.getInstance().setUserId("TestUserId");
}
3-6.Bind buttons and interfaces in scripts

- Step1. Click “+” to add a function
- Step2. Choose a the corresponding scene which has the interface you want to use
- Step3. Click the “No Function” select to choose the script and then choose the corresponding function

Demo Project:How to use this demo project?
After integration, you can create a crash and report the crash for testing, please refer to here: https://developer.huawei.com/consumer/cn/doc/development/AppGallery-connect-Guides/agc-crash-test
If there are still things not clear you can check the demo on github. The corresponding crash usage is https://github.com/Unity-Technologies/HuaweiServiceSample/blob/master/Assets/HuaweiServiceDemo/Scripts/test/location/CrashTest.cs
After writing and testing the code according to this Demo Project, the crash information you created will be uploaded to the crash service page, as shown in the following document https://developer.huawei.com/consumer/cn/doc/development/AppGallery-connect-Guides/agc-crash-locate
You can also set the user ID according to our API setting custom user identifier, add custom logs, add custom key-value pairs, etc. According to the custom information you set, you can get a custom crash report. The usage is as follows: https://developer.huawei.com/consumer/cn/doc/development/AppGallery-connect-Guides/agc-crash-customreport