How Can I Integrate Crash of AppGallery Connect in React Native?

Mayism

Senior Member
Nov 5, 2020
57
7
18
github.com
HUAWEI AppGallery Connect Crash supports multiple platforms. Here’s how you can integrate the AppGallery Connect React Native plug-in. If you want to experience the remote configuration function, see the GitHub demo.

Integration Procedure
1. Install the React Native dependency.

npm install -g yarn

2. Create a project and enable Remote Configuration.

a) In AppGallery Connect, create an Android app, add the app to a project, and enable Crash and HUAWEI Analytics for it.


b) Run the following command to create a React Native project. In this example, name the project rncrashdemo.

npx react-native init rncrashdemo

c) Add the configuration file to your React Native project.

Add the agconnect-services.json file to the android/app directory of the React Native project.


d) Configure the Maven repository address and AppGallery Connect plug-in address.

1) Open the build.gradle file in the android directory of your React Native project.
Go to allprojects > repositories and configure the Maven repository address.
Go to buildscript > repositories and configure the Maven repository address.
Go to buildscript > dependencies and configure the AppGallery Connect plug-in address.

2) Add build dependencies and the AppGallery Connect plug-in address.

Open the build.gradle file in the android/app directory of the React Native project and add the plug-in address.


3. Install the plug-in.

In the project directory, run the following command to install the Crash plug-in.
npm install @react-native-agconnect/crash

4. Test the Crash service.

You can set a button to determine whether to report crashes. Create another button for testing. Click the button, call setUserId to set a custom user ID, call setCustomKey to set a custom key-value pair, call LogLevel to customize the log level, and call testIt to trigger a crash.


5. Install an app.
Run the yarn android command to install your app.
Viewing a Crash Report
After integration, click the test button to trigger a crash and generate a custom crash report. You can view the report in AppGallery Connect.

1. Select Last hour.

2. View details about crash stack information.

3. View custom key-value pairs.

4. View custom log levels.

5. View custom user IDs.
Reference
1. HUAWEI AppGallery Connect Crash documentation: https://developer.huawei.com/consum...Gallery-connect-Guides/agc-crash-introduction
2. HUAWEI AppGallery Connect Crash demo: https://github.com/AppGalleryConnect/agc-reactnative-plugin/tree/master/agc-crash-reactnative
 
Last edited: