[Huawei Developers] Mayism:
According to Huawei official document, AppGallery Connect Crash 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. The SDK integrated into your app can automatically collect crash data and report the data to AppGallery Connect when your app crashes, helping you understand the version quality of your app, quickly locate the causes of crashes, and evaluate the impact scope of crashes.

In other words, Huawei provides an SDK. You can view the crash information of your app as long as you integrate it. No code is required. Isn't it great? Let's see how it works.

Creating Your Project and App

First, you need to create a project in AppGallery Connect and add an app to it. For details, see the AppGallery Connect documentation.

Enabling HUAWEI Analytics

The Crash service uses capabilities of HUAWEI Analytics when reporting crash events. Therefore, you must enable HUAWEI Analytics before integrating the Crash SDK. For details, please refer to the AppGallery Connect documentation.

Integrating SDKs

If you are using Android Studio, you need to integrate the Crash SDK into your Android Studio project before development.

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

2. Find the project you created from the project list, and click the app for integration on the project card.

3. Go to Project Settings > General information, and click agconnect-services.json under App information to download the configuration file.

4. Copy the agconnect-services.json file to the app's root directory of your Android Studio project.

5. Open the build.gradle file in the root directory of your Android Studio project, and configure the Maven repository address and AppGallery Connect plug-in address.

buildscript {
repositories {
google()
jcenter()
maven { url 'https://developer.huawei.com/repo/' }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
classpath 'com.huawei.agconnect:agcp:1.4.1.300'
}
}

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

6. Integrate the latest versions of the Analytics SDK and Crash SDK.

dependencies {
implementation 'com.huawei.hms:hianalytics:5.0.4.200'
implementation 'com.huawei.agconnect:agconnect-crash:1.4.1.300'
}

7. Click Sync Now to synchronize the configuration.

Testing the Crash Service

You can create a test button CrashTest in your demo project, and call the testIt method provided by AppGallery Connect to trigger a crash.

The sample code for creating the button is as follows:

<Button
android:id="@+id/btn0"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize= "22dp"
android:textAllCaps="false"
android:text="CrashTest" />

The sample code for a tapping event is as follows:

Button btn_crash0 = findViewById(R.id.btn0);
btn_crash0.setOnClickListener(new View.OnClickListener() {
[MENTION=439709]override[/MENTION]
public void onClick(View view) {
AGConnectCrash.getInstance().testIt(MainActivity.this);
}
});

Package and run your app, and tap the CrashTest button to trigger a crash.

Viewing a Crash Report

You can view the details of the crash that you just triggered in AppGallery Connect.

1. Sign in to AppGallery Connect, go to My projects, and click your app.

2. Go to Quality > Crash. On the Crash page, click the Statistics tab, and view crash statistics of your app. The crash information is displayed 1 or 2 minutes after you run your app.

3. Click the Problems tab, and view the crash of your app. For example, in the following figure, java.lang.NullPointerException is the null pointer issue triggered during the test.

Click the crash to view its details. The possible causes of the crash are displayed, as shown in the following figure, helping you analyze the crash.

Summary:

1. It is easy to integrate the Crash service. During testing, you can either write code yourself, or use the testIt method provided by AppGallery Connect.

2. Crash reports are available in only 1 or 2 minutes.

3. All you need to write is just a few lines of code during testing. The service integration for app release is coding-free.

4. The Crash service also provides features including monitoring NDK crash reports, restoring obfuscated reports, and generating custom reports.

For more details, check:

HUAWEI AppGallery Connect Crash documentation: https://developer.huawei.com/consum...Gallery-connect-Guides/agc-crash-introduction

Huawei AGC Crash codelab:

https://developer.huawei.com/consumer/en/codelab/CrashService/index.html#0