The 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. 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 this codelab, you will create an app that can integrate the Crash service and manually trigger a crash to test the Crash service.
To integrate the Crash service of AppGallery Connect, you must complete the following preparations:

dependencies {
// Configure the following address:
implementation 'com.huawei.agconnect:agconnect-crash:1.6.2.300'
implementation 'com.huawei.hms:hianalytics:6.3.2.300'
}

In this codelab, you can create a layout page in your Android Studio project and design the UI according to the following figure, with one makeCrash button to trigger a crash event.
Sample code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical">
<LinearLayout
android:layout_width="300dp"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical">
<Button
android:id="@+id/btn_crash"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAllCaps="false"
android:text="makeCrash" />
</LinearLayout>
</LinearLayout>
In this codelab, you can test the Crash service by calling the API of the Crash SDK to trigger a crash and then checking whether the crash data is reported in AppGallery Connect. The procedure is as follows:
Button btn_crash = findViewById(R.id.btn_crash);
btn_crash.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
AGConn***getInstance***tInstance().testIt(MainActivity.this);
}
});



Congratulations! You have successfully created an app integrated with the Crash service of AppGallery Connect and learned how to view and analyze crashes in AppGallery Connect. You can also trigger different types of crashes and view them in AppGallery Connect.