[Huawei Developers] John Wo:
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:

Create an app in AppGallery Connect and enable APM.

Download and add the JSON file.

Integrate the APM plug-in and the APM SDK.

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.

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/025/805/385/5190049000025805385.20201102013254.28231856932804055992857423218488:50511116074726:2800:1F8ED4C158E9AEDFFCD6E6B291C8903F1A7CC385B2BC8010C9CDDCAD4D572351.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/025/805/385/5190049000025805385.20201102013254.28231856932804055992857423218488:50511116074726:2800:1F8ED4C158E9AEDFFCD6E6B291C8903F1A7CC385B2BC8010C9CDDCAD4D572351.png[/IMG]

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.

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/025/805/385/5190049000025805385.20201102013554.84572436831232048779188244658205:50511116074726:2800:0B0B16FCEA009FCA1BFED86CD0E00BC6165AA768AA2717C03719E106B7F23F31.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/025/805/385/5190049000025805385.20201102013554.84572436831232048779188244658205:50511116074726:2800:0B0B16FCEA009FCA1BFED86CD0E00BC6165AA768AA2717C03719E106B7F23F31.png[/IMG]

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

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/025/805/385/5190049000025805385.20201102013608.48068110140223699358784593676598:50511116074726:2800:BABFC17A4FC99540B5409192F1A881EC4DCB56D03F732BDAB7CE7FAA34F7C621.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/025/805/385/5190049000025805385.20201102013608.48068110140223699358784593676598:50511116074726:2800:BABFC17A4FC99540B5409192F1A881EC4DCB56D03F732BDAB7CE7FAA34F7C621.png[/IMG]

3.2 App Analysis

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/025/805/385/5190049000025805385.20201102013622.66551279267140337528202181617763:50511116074726:2800:245A5AC88AC11069E21B555F7643896A2050825F95E9D165D05B7016EEDEDE8F.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/025/805/385/5190049000025805385.20201102013622.66551279267140337528202181617763:50511116074726:2800:245A5AC88AC11069E21B555F7643896A2050825F95E9D165D05B7016EEDEDE8F.png[/IMG]

3.3 ANR Analysis

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/025/805/385/5190049000025805385.20201102013636.34159625878971067650248925816832:50511116074726:2800:4299EB71CF9ED11A0B00C077CAF4D74FD9A485BBDDCA22246C6BD8E96781D4D7.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/025/805/385/5190049000025805385.20201102013636.34159625878971067650248925816832:50511116074726:2800:4299EB71CF9ED11A0B00C077CAF4D74FD9A485BBDDCA22246C6BD8E96781D4D7.png[/IMG]

3.4 Network Analysis

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/025/805/385/5190049000025805385.20201102013747.37210886106975228867316200627601:50511116074726:2800:153A335D602B9C6B62DF755ABA463EF2BD5073C17B430BD7B428FF20ECEAD604.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/025/805/385/5190049000025805385.20201102013747.37210886106975228867316200627601:50511116074726:2800:153A335D602B9C6B62DF755ABA463EF2BD5073C17B430BD7B428FF20ECEAD604.png[/IMG]

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