Android | Quickly integrate AGC crash service with zero code

According to the official introduction: AGC crash service provides a lightweight crash analysis service. According to the Crash SDK, zero-code quick integration can be achieved. Your application can automatically collect crash reports when it crashes, helping you understand the quality of the application version and the problem of crash Perform fast tracking and positioning, assess the impact of the crash problem, etc.

To put it bluntly, Huawei provides an SDK, you can see the crash information of the application as long as you integrate it, without any code. Is it very exciting? Don't say much, try first.

Create projects and applications

First, you need to create a project in AGC, and add an application to the project. The operation is very simple. You can refer to the official document to create an application here.

Open Huawei analysis service

Since the crash service uses the capabilities of Huawei analysis services when reporting crash events, it is necessary to activate Huawei analysis services before integrating the Crash SDK. Please refer to the official documentation to enable Huawei analysis.

Integrated SDK

For the Android Studio development environment, the Crash SDK needs to be integrated into the Android Studio project just created before development.

  1. Log in to the AppGallery Connect website and click "My Project".

  2. Find your project in the project list, and select the application you just created that needs to be integrated in the application list under the project.

  3. Click "agconnect-services.json" under "Application" in "Project Settings" to download the configuration file.
    Insert picture description here

  4. Copy the "agconnect-services.json" file to the application-level root directory.
    Insert picture description here

  5. Open the Android Studio project-level build.gradle file and configure the plugin and warehouse 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/'   }
      }
  }
  1. Open the Android Studio application-level build.gradle file, configure and integrate the latest version of 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'
              }
  1. Click the "Sync Now" link on the interface to synchronize the completed configuration.
    Insert picture description here

Crash test

In order to test the crash, here I added a button "CrashTest" to the demo, click to call the AGC's own method to cause the crash, and then see the effect.

The key design code 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 click event code is as follows:

 Button btn_crash0 = findViewById(R.id.btn0);
  btn_crash0.setOnClickListener(new View.OnClickListener()   {
      @Override
      public void onClick(View   view) {
          AGConnectCrash.getInstance().testIt(MainActivity.this);
      }
  });

Package and install the application on the phone and click "CrashTest" to cause a crash.

Crash report view

You can view the details of the crash that was just manually created on the AGC.

  1. Log in to the AppGallery Connect website and click the "My Project" icon to enter the application.

  2. Click "Quality> Crash" to enter the crash page. In the page, click the "Statistics" tab. By default, "Last 24 hours" is displayed. You can see that the crash information has been reported. Please note that you need to wait for 1-2 minutes. To see.
    Insert picture description here

  3. Click on the "Problems" tab to view the crash problem. "java.lang.NullPointerException" is displayed. The manual creation is indeed a null pointer crash.
    Insert picture description here

Continue to click on the crash problem to view the details, you can see the detailed cause of the crash problem, to help you analyze the crash problem, the following shows that clicking "CrashTest" crashed.
Insert picture description here

to sum up:

1. The integrated crash service is very simple, you can write your own code when testing, or you can use the testIt method that comes with AGC.

2. The crash report is displayed very quickly, usually within 1-2 minutes.

3. In addition to writing a few lines of code for testing, the application is officially launched as long as the SDK is integrated, which is truly zero code.

4. The crash service also provides NDK crash monitoring, confusing crash report restoration, custom reports, etc., which are very powerful.

For more details, please see:

Huawei AGC crash service development document:https://developer.huawei.com/consumer/cn/doc/development/AppGallery-connect-Guides/agc-crash-introduction

Huawei AGC crash service codelab document:https://developer.huawei.com/consumer/cn/codelab/CrashService/index.html#0


Original link:https://developer.huawei.com/consumer/cn/forum/topic/0201387764119030047?fid=0101271690375130218
Author: Drum Chao

Guess you like

Origin blog.51cto.com/14772288/2544463