How to use Huawei Crash Service

Melike Karayılan
Huawei Developers
Published in
5 min readJun 22, 2020

Hi everyone.

In this article, I will explain how to use Huawei Crash Service.

Although apps are tested many times before they released, there still can be crashes. There is a Huawei Crash Service to minimize these 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.

Integrating the AppGallery Connect Sdk

To use Huawei Services we should make an integration between the projects we created in AppGallery and Android Studio.

After creating the project in AppGallery, we add the agconnect-service.json file to the project which is in Android Studio.

After adding to configuration file to project, you need to added the codes which they are shown below to your project.

Allprojects > repositories

allprojects {  
repositories {
google()
jcenter()
maven {url 'https://developer.huawei.com/repo/'}
}
}

Buildscript > repositories

buildscript {  
repositories {
google()
jcenter()
maven {url 'https://developer.huawei.com/repo/'}
}
}

Buildscript > dependies

buildscript {  
dependencies {
classpath 'com.huawei.agconnect:agcp:1.3.2.301'
}
}

And then open the build.gradle file in the app directory.

apply plugin: 'com.huawei.agconnect'

Configure build dependencies.

dependencies {       
implementation 'com.huawei.agconnect:agconnect-core:1.3.2.301'
}

HUAWEI Analytics Kit needs to be enabled before integrating the Crash SDK :

You need to set information which they are data storage location, time zone, currency, user data storage time and calendar week, After this process.

Then add the following codes to the build.gradle file.

implementation 'com.huawei.hms:hianalytics:{version}'
//
implementation 'com.huawei.agconnect:agconnect-crash:1.3.2.301

You need to set the data storage location when enabling the Crash service. Then, the setting in agconnect-services.json will be automatically updated accordingly. If you enable the Crash service for the first time, you need to download the agconnect-services.json file again and integrate it into your project after the service is enabled.

To see if Crash Service works properly, you don’t need to wait your app to crash since the AGConnectCrash can be triggered manually.

There are 2 different ways to trigger the AGConnectCrash:

AGConnectCrash.getInstance().testIt(context);
//
AGConnectCrash.getInstance().enableCrashCollection(true);

Used sample of these methods are in the following:

https://developer.huawei.com/consumer/en/doc/development/AppGallery-connect-Guides/agc-crash-test

Configuring a Mapping File

If the obfuscation function is enabled in the build.gradle file, the ProGuard and DexGuard tools override the class names, fields, and methods in the code during building which cause unreadable information. Mapping file should be uploaded and unreadable code should be restored to avoid this issue.

There are 2 different ways to upload the mapping file:

· Use the Gradle plug-in to upload a mapping file when integrating the Crash SDK.

· Manually upload a mapping file on the AppGallery Connect Crash service page when a crash occurs.

Use following steps in the link to upload the mapping file:

https://developer.huawei.com/consumer/en/doc/development/AppGallery-connect-Guides/agc-crash-mapping

Analyzing the Crash

Crash Service automatically reports the occurred crashes to AppGallery Connect. Details and the cause of crash can also be viewed in the statistics page on AppGallery Connect.

How to access to the Crash Service Page:

1. Sign in to AppGallery Connect and select My projects.

2. Find your project from the project list and click the app for which you need to check crash data.

3. Go to Quality > Crash. The Crash page is displayed.

Statistics page also allows you to specify the filters:

Reported crashes can be seen under the problems tab:

To Customize the Treshold

1. Sign in to AppGallery Connect and select My projects.

2. Find your project and select an app from the app list.

3. Choose Quality > Crash in the navigation tree on the left and click Set crash notification.

4. Select 0.1%-1% or 1%-10% and move the slide bar to set a specific threshold. Then, click OK.

To Enable Crash Notifications:

1. Sign in to AppGallery Connect and select Users and permissions.

2. Go to User > Personal information.

3. In the Notification area, select the check box under Email for Crash notification (Notify me of a major crash).

Crash SDK Data Security

The Crash SDK works dependently on the request.

Following permissions can be declared on the Crash SDK:

android.permission.ACCESS_NETWORK_STATE

android.permission.INTERNET

Types of data Crash SDK collects:

Common event attributes: AAID, Android ID (obtained when AAID is empty), system type, system version, ROM version, device brand, system language, device model, whether the device is rooted, screen orientation, screen height, screen width, available memory space, available disk space, and network connection status.

App data: APK name, app version, crashed stack, and thread stack.

SDK Data Protection

The Crash SDK collects data locally and reports data to the collection server through HTTPS after encrypting the data.

The use and integration of the Huawei Crash Service is quite simple and easy to apply since it does not require coding. Plus, it helps minimizing the risks and analyzing occurred crashes as we’ve mentioned before.

--

--