AGC- Crash Service (Android)

Cenk Türker
Huawei Developers
Published in
7 min readDec 4, 2020

Hello everyone, in this article I am going to talk about Crash services which one of the AppGallery Connect services.

Crash Service

What is the crash service ?

The crash service of AppGallery Connect reports crashes automatically and allows crash analysis after integrating the crash service, your app will automatically report crashes to AppGallery Connect for it to generate crash reports in real time. The abundant information provided in reports will help you locate and resolve crashes.

Why do we need the crash service ?

Although apps have gone through rounds the tests before release considering the large user base diverse device models and complex network environment. it’s inevitable for apps to crash occasionally. Crashes compromise user experience, Users may even uninstall you app due to crashes and your app is not going to get good reviews.

You can’t get sufficient crash information from reviews to locate crashes, Therefore you can’t resolve them shortly. This will severely harm your business. That’s why we need to use the crash services in our apps to be more efficient.

How can we integrate Crash service ?

It’s piece of cake ! , you only need to integrate the Crash SDK to your app. Then the SDK can implement related functions without any coding. I’m going to tell you how to implement the SDK in progressive section.

Getting Started on Crash Service

There are some procedures that you need to apply it into your own app.Here is the following steps ,go for it;

1-Integrating the AppGallery Connect SDK

You will find out whole necessary information about how to integrate the SDK on AppGallery Connect.

2-Enabling HUAWEI Analytics Kit

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

3-Integrating HUAWEI Analytics Kit

Before using HUAWEI Analytics Kit, you must integrate it by adding the following code to the app-level build.gradle file (usually in the app directory):

hianalytics in build.gradle

4-Integrating the Crash SDK

Add the following code to the app-level build.gradle file (usually in the app directory) to integrate the Crash SDK:

agconnect-crash in build.gradle

After applying these steps, don’t forget to click on“Sync Now” button on the right top to rebuild with updated version of your project.

AndroidManifest Permission

Also,you need to add these below permission commands into your Androidmanifest.xml.

AndroidManifest.xml

Code Development Part

You can see piece by piece code blocks in MainActivity.java

Add the code for calling the AGConnectCrash.testIt method to trigger a crash when the makeCrash button is tapped.

Add the code for calling the AGConnectCrash.enableCrashCollection method to enable crash data reporting when the CrashCollectionON button is tapped.

CrashCollectionON

Add the code for disabling crash data reporting when the CrashCollectionOFF button is tapped.

CrashCollectionOFF

Add the code for calling AGConnectCrash.setUserId to define a custom user ID, calling AGConnectCrash.log to record custom logs, and calling AGConnectCrash.setCustomKey to define a custom key-value pair when the CustomReport button is tapped.

Custome Report — Key-Value

Here is the all MainActivity.xml layout, it creates application interface.

The app interface you will see after applying xml to your own project is as follows.

So, we completed code development part, the next step is tracking and analysing results at AppGallery Connect ,after executing your project.

Enabling Crash Service On AppGallery Connect

After signing AppGallery Connect ,you need to follow these steps to enable crash service, if you are going to use it first time.

My project →Project Settings → Quality → Enable Now

How can we resolve the existing crashes ?

With signing in to AppGallery Connect ,you can check crash indicators including number of crashes, number of affected users and crash rate. You can filter date by time ,OS, app version, device type and other criteria to find the crash you want to resolve. In addition, you can check the details of the crash, locate the crash accordingly or directly go to the code where the crash occurs based on the crash stack and resolve the crash.

What is crash notification ?

The crash service will monitor your app in real time for crashes, When a critical crash occurs, if you have enabled the notification function, you will receive email notifications , so you can resolve them promptly.

How to Enable Crash Notifications ?

Please follow the below steps 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 boxes under Email and SMS message for Crash notification (Notify me of a major crash) and click Save.

Monitoring & Analyzing Crash Service Test Result

After completing configuration process, you can see the results for your crash services.

In “Statistics ” tab, you will find out some outputs about crash. Such as;

  • How much times your app crashed,
  • Crash Rate,
  • Affected Users,
  • In time type

Additionally, you can select “Add Filter” on left top and check out the result as;

  • Operating System
  • App version,
  • Device
Crash

However, you can customize the threshold with clicking on “Set crash notification”.

Set Crash Notification

You can also download report by clicking on “Download Report” to verify in .csv format the all crash results.

In ”Problems ” tab, you can view main problem of crash’ occuring reaason.

additively, can check out ;

  • Event Type,
  • Event,
  • Affected User,
  • Last occurence time.
Problems tab

After clicking on the name of the problem which is “java.lang.NullPointerException” here, you will get a chance to examine in detail.

In below table, you will have information to check such as;

  • Stack,
  • Logs,
  • Status,
  • Information.

Now we are going to explain above matters ,after that jump into “Search by User” tab.

Stack tab

In “Logs” tab , you can go through logs by filtering according to ;

  • All
  • Debug,
  • Info,
  • Warning
  • Error

Also you can get search with using the box named as “Enter a keyword”.

Log tab

In “Status” tab , To obtain the app status in which a crash occurs, you can add a custom “key-value” pair to record the status. Actually here, you will have examine your own custom values that you created to occur crash.

Status tab

In “Information” tab, you take a look at information about your ;

  • App
  • Operating System
  • Device
Information tab

In “Search by user” tab, you will find out some outputs about crash’s ;

  • Occuring time,
  • User ID,
  • Event type,
  • Problems

Customizing a Crash Report

if you want , you can create your own crash report by customizing these red marked area parameters.So that your analyz will be more efficient and understandable.

customizing own crash report

FAQ’s

Q:Can I get export the all crash reports from AppGallery Connect ?
A:Yes sure, you can download as report .csv format in your own AGC crash page.

Q:Can I see through AGC that my application has been crashed for whatever reason?
A:Yes you can , clicking on through Problems tab, you will see 4 different tab named as Stack, Logs, Status and Information, each tab will give you different solution about what you are looking for

Q:Why can’t ı see the crash report immediately in AGC ,when I run the test in my app ? Is there any duration to see and how long data is stored ?
A:The reflection of the test report to you is at least 1 minute on average, and this data provides you with the results of hourly, 24-hour and 7-day, 30-day and 90-day data.

We have come to the end of my article, I hope what I mentioned will be useful to you, see you in my next article, I wish you all have a nice day…

References

--

--