Coding-Free Integration of AppGallery Connect Crash in Flutter
Learn how to integrate the AppGallery Connect Flutter plug-in in this simple 5-step tutorial. You’ll also learn how to view a crash report.
Join the DZone community and get the full member experience.Join For Free
HUAWEI AppGallery Connect Crash supports multiple platforms. Here’s how you can integrate the AppGallery Connect Flutter plug-in. If you want to try the crash service, see the GitHub demo.
1. Install the Flutter Environment
a) Download the Flutter SDK package from https://flutter.dev/docs/get-started/install/windows.
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.
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.
b) In Android Studio, create a Flutter project.
c) Add the agconnect-services.json file to the android/app directory.
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.
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.
3. Integrate the Crash SDK
Add the SDK dependency of Crash to the pubspec.yaml file.
Click Pub get to synchronize the data.
After the data is synchronized, you can view the downloaded file here:
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.
5. Package the APK File
Similar to Android, you only need to run your project in Android Studio.
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.
- Select Last hour.
- View details about crash stack information.
- View custom key-value pairs.
- View custom log levels.
- View customer user IDs.
- Generate and upload a mapping file to de-obfuscate the crash report.
For more details, please check:
- HUAWEI AppGallery Connect Crash documentation: https://developer.huawei.com/consumer/en/doc/development/AppGallery-connect-Guides/agc-crash-introduction
- HUAWEI AppGallery Connect Crash codelab: https://developer.huawei.com/consumer/en/codelab/CrashService/index.html#0
- GitHub documentation: https://github.com/AppGalleryConnect/agc-demos/tree/main/Flutter/agc-crash-flutter
Published at DZone with permission of Li Mayism. See the original article here.
Opinions expressed by DZone contributors are their own.