What Should I Do If the Crash Report Cannot Be Obtained When Using the Crash Service?
Tags: android, appgallery, mobile, crashlytics
Published: 2021-07-22 12:25:53

The Crash service of HUAWEI AppGallery Connect allows you to effortlessly complete service integration by adding the Crash SDK with no coding needed. Despite this, after integrating the service, you may fail to obtain crash reports in AppGallery Connect. You can locate the fault as follows:

1.	Check whether app crashes have been reported.
Run the adb shell setprop log.tag.AGC_LOG VERBOSE command to enable the debugging mode of the Crash SDK. The message "upload success" indicates that the crash data is reported successfully by the app. If the message is not displayed, check the integration of the Crash SDK.

![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/06ed3cggn0i9mcxdqzli.png)
 
If no crash data is reported, call the testIt API to trigger a crash and add the following code to print the value of the crash handler.

```java
Button btn_crash = findViewById(R.id.btn_crash);
        btn_crash.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                final String clzName = getTheDefaultCrashHandler();
                if(isAGCCrashHandler(clzName)){
                    AGConnectCrash.getInstance().testIt();
                } else{
                    Toast.makeText(MainActivity.this,
                            "the default crash handler is " + clzName,
                            Toast.LENGTH_SHORT).show();
                }
            }
        });

    private boolean isAGCCrashHandler(String clz){
        if(clz.startsWith("com.huawei.agconnect.crash")) {
            return true;
        }
        return false;
}
    private String getTheDefaultCrashHandler(){
        Thread.UncaughtExceptionHandler defCrashHandler = Thread.getDefaultUncaughtExceptionHandler();
        return defCrashHandler.getClass().getName();
    }
```

Ensure that the default crash handler is AppGallery Connect. If you have enabled other third-party crash services, AppGallery Connect Crash may fail to be initialized before the app crashes. In this case, you can disable all third-party crash services and try again. If it works, ensure that all integrated crash services do not conflict with each other.

2.	If the crash is reported but not displayed in AppGallery Connect, perform the following operations:

2.1	Ensure that your phone is connected to the Internet.

2.2	Ensure that the JSON file is added to the project after HUAWEI Analytics is enabled. The following information is contained in the JSON file.
![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3ppk7k45j5qjaru0h2yz.png)
 
 
2.3	Open the app again. Java crashes are reported immediately, while NDK crashes are reported when the app is reopened.

2.4	Go to **HUAWEI Analytics > Overview > Real-time overview** in AppGallery Connect and check whether the data is reported.
![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s9zdp9hzubh1kt2jn3mg.png)
 
 
2.5	Go to Quality > Crash. Click both the Statistics and Search by user tabs to check whether there is a report. Sometimes the crash report is displayed on the Search by user tab page instead of Statistics by HUAWEI Analytics. The possible cause for this is because real-time data collection is stacked. In this case, contact Huawei technical support.

Reference: [development guide of the Crash service](https://developer.huawei.com/consumer/en/doc/development/AppGallery-connect-Guides/agc-crash-test-0000001055420516)