Coding-free Integration of AppGallery Connect Crash in Flutter

Search This thread

Mayism

Senior Member
Nov 5, 2020
133
26
github.com
HUAWEI AppGallery Connect Crash supports multiple platforms. Here’s how you can integrate the AppGallery Connect Flutter plug-in.If you want to quickly experience this service, see the demo on GitHub.

Integration Procedure
1. Install the Flutter environment.
a) Download the Flutter SDK package from https://flutter.dev/docs/get-started/install/windows.
0*EJXXpG45mGfu_0Oy.png

Decompress the package to any directory.
b) Add the Flutter command file to the environment variable.
c) Download the Flutter and Dart plug-ins in Android Studio.

0*wWbiRC4HK9wboDmw.png

2. Create a project and enable Crash.

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

0*BG3kRNqlySJnMmz7.png

b) In Android Studio, create a Flutter project.

0*zy1xDLZbqxNe-QgV.png

c) Add the agconnect-services.json file to the android/app directory.

0*gBcb6tIAikE2jXkJ.png

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

1) Open the build.gradle file in the android directory of the Flutter project.
Go to allprojects > repositories and configure the Maven repository address for the AppGallery Connect SDK.
Go to buildscript > repositories and configure the Maven repository address for the AppGallery Connect SDK.
Go to buildscript > dependencies and configure the AppGallery Connect plug-in address.
0*Gp7gW07ckRlZPL1J.png

2) Add build dependencies and the AppGallery Connect plug-in address.
Open the build.gradle file in the android/app directory of the Flutter project and add the plug-in address.
0*_3hZM3cnXuMnr4Yn.png

3. Integrate the Crash SDK.
Add the SDK dependency of Crash to the pubspec.yaml file.
0*WwbdltuEKcjg28J3.png

Click Pub get to synchronize the data.

0*HOhWp8b6KhfcJDsx.png

After the data is synchronized, you can view the downloaded file here.

0*4CLbxc-tIM_uoiRY.png

4.Test the Crash service.

You can set two buttons 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.

0*oTlZeBXCQU7O55nG.png
0*CYqjV9YgEtBt1HoA.png

5. Package the APK file.
Similar to Android, you only need to run your project in Android Studio.
0*w32H8-iFe_FZOCtJ.png
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.
0*_lnAgkHxDObX40YL.png

2、View details about crash stack information.
0*pz1EdVu9zRyiS1Bx.png

3、 View custom key-value pairs.
0*cixH-NEB8Z3vr6Dt.png

4、 View custom log levels.
0*rYwj2y5OWyvWmen0.png

5、 View custom user IDs.
0*9HP67z4TaEsk_RYY.png

6、Generate and upload a mapping file to de-obfuscate the crash report.
0*W6p-d2laaSEKEzmV.png
0*uePK02-1UV4X4CxP.png

For more details, please check:

1、HUAWEI AppGallery Connect Crash documentation: https://developer.huawei.com/consum...Gallery-connect-Guides/agc-crash-introduction
2、HUAWEI AppGallery Connect Crash codelab: https://developer.huawei.com/consumer/en/codelab/CrashService/index.html#0
https://github.com/AppGalleryConnect/agc-demos/tree/main/Flutter/agc-crash-flutter
 
Last edited: