Huawei Developers
Published in

Huawei Developers

Coding-free Integration of AppGallery Connect APM on Android Platform

When an app is used, such problems may occur: slow app launch, Application Not Responding (ANR), app crash, and network loading failure. These are the major issues that affect user experience.

To meet increasing demands of diagnosing performance problems, more and more app performance monitoring services have emerged in the market. HUAWEI AppGallery Connect provides full-process quality services in app development, testing, release, and analysis.

1. HUAWEI AppGallery Connect APM

App Performance Management (APM) is one of the quality services provided by AppGallery Connect. This service can monitor app performance at the minute level, and is totally free of charge. It does its job by:

  • Collecting data about app launches, app screen rendering, network requests, and foreground/background activities automatically.
  • Monitoring ANR problems and recording relevant device information and log information when they occur.
  • Providing app performance data analysis reports for app optimizations.
  • Supporting custom traces to monitor app performance data in specific scenarios.

AppGallery Connect APM has the following edges over other app performance monitoring platforms:

  • Easy integration: You can integrate APM for app performance analysis without any coding.
  • Real-time monitoring: It takes only 15 minutes to generate a report based on collected performance data.
  • Comprehensive metrics: APM illustrates an app’s performance in a myriad of dimensions such as app launches, ANR, screen rendering, and network requests, and also supports custom traces, indicators, and dimensions to provide a tailored report for your specific needs.

2. Integrating AppGallery Connect APM

You can easily complete the integration of the service by following instructions in the documentation provided by Huawei. You only need to add the required plug-in and SDK configurations to your code without any coding. There are just a few simple steps:

  1. Create an app in AppGallery Connect and enable APM.
  2. Download and add the JSON file.
  3. Integrate the APM plug-in and the APM SDK.
  4. Configure the obfuscation file.

Then, you can package and run your app, and view its performance data later in AppGallery Connect.

2.1 Creating an App in AppGallery Connect and Enabling APM

Access AppGallery Connect, create an app, and enable APM. Ensure that your app package name is the same as that configured in the APK file. If you need to enable APM for an existing app, make sure that the app package name in the APK file is the same as that configured in AppGallery Connect when the app is created.

Then select an app under My projects, go to Quality > APM, and click Enable.

2.2 Downloading and Adding the JSON File

Create an Android project in Android Studio. The package name must be the same as that in AppGallery Connect.

In AppGallery Connect, select an app under My projects, go to Project settings > App information, download agconnect-services.json, and place the file in the app directory of your Android project.

2.3 Integrating the APM Plug-in and the APM SDK

To configure the SDK address, open your Android project, and configure the following content in the project-level build.gradle file.

buildscript {repositories {// Configure the following address:maven {url 'https://developer.huawei.com/repo/'}}dependencies {// Configure the following address:classpath 'com.huawei.agconnect:agcp:1.4.1.300'classpath 'com.huawei.agconnect:agconnect-apms-plugin:1.3.1.300'}}allprojects {repositories {// Configure the following address:maven {url 'https://developer.huawei.com/repo/'}}}

Open the app-level build.gradle file, and configure the following content.

// Configure the following address:apply plugin: 'com.huawei.agconnect'apply plugin: 'com.huawei.agconnect.apms'dependencies {// Configure the following address:implementation 'com.huawei.agconnect:agconnect-apms:1.3.1.300'}

2.4 Configuring the Obfuscation File

Find the app-level proguard-rules.pro file (confusion configuration file), and add the following items:

-keep class com.huawei.agconnect.**{*;}-dontwarn com.huawei.agconnect.**-keep class com.hianalytics.android.**{*;}-keep class com.huawei.updatesdk.**{*;}-keep class com.huawei.hms.**{*;}-keep interface com.huawei.hms.analytics.type.HAEventType{*;}-keep interface com.huawei.hms.analytics.type.HAParamType{*;}-keepattributes Exceptions, Signature, InnerClasses, LineNumberTable

For how to find the file, see the following figure.

2.5 Packaging the App for Testing

After integration, click Sync in the upper right corner of your project in Android Studio to package and run your app on an Android device. Then, you can view the data in AppGallery Connect.

For more data, you can install and run the app on multiple devices.

3. Viewing Performance Data and ANR Data

Once you have run your app on a device, go back to AppGallery Connect. Find the app under My projects, go to Quality > APM, and view its performance data during testing.

As mentioned before, the performance data that you can view is diverse. The following is a sample report for your reference:

3.1 Overview

3.2 App Analysis

3.3 ANR Analysis

3.4 Network Analysis

4. Summary

In only 4 steps, you can integrate the HUAWEI AppGallery Connect APM SDK without coding, to implement comprehensive app performance monitoring.

The APM analysis report provides detailed device, log, and performance information recorded when an issue occurs. This real-time report drives app operations based on data and provides abundant information for app optimizations. App R&D and operations personnel no longer need to spend much time on locating and reproducing performance problems.

For more details, check:

AppGallery Connect APM development guide:

https://developer.huawei.com/consumer/en/doc/development/AppGallery-connect-Guides/agc-apms-introduction

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store