[Huawei Developers] Mayism:
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.If you want to quickly experience this service, see the demo on GitHub.

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.

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

As described in Huawei document, you can easily complete the integration of the service by adding the required plug-in and SDK configurations to your code without any coding. There are just a few simple steps:

i. Create an app in AppGallery Connect and enable APM.

ii. Download and add the JSON file.

iii. Import the HuaweiService package to Unity Editor.

iv. Integrate the APM plug-in and the APM SDK.

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

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. 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.

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

2.2 Configuring the Android Environment in Unity Editor and Downloading the JSON File

1. Choose Edit > Project Settings > Player > Publish Settings. In the Build area, select items for Android as required.

2. In Unity Editor, choose Edit > Project Settings > Player > Other Settings, and set the package name to the one you set in AppGallery Connect.

2.3 Importing the HuaweiServices Package

1. Download the package here.

2. Choose Assets > Import package.

3. Select the required package, and click Import.

4. In AppGallery Connect, click My projects, and find your project from the list. Go to Project settings > General information, download the agconnect-services.json file, and save the file to the Assets\Plugins\Android directory of your Unity project.

2.4 Integrating the APM SDK into Your Unity Project

1. Add the following code to the project-level baseProjectTmeplate.gradle file in the Assets\Plugins\Android directory:

allprojects {
buildscript {
repositories {
maven { url 'https://developer.huawei.com/repo/' }
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.0'
classpath 'com.huawei.agconnect:agcp:1.4.2.301'
classpath ''com.huawei.agconnect:agconnect-apms-plugin:1.4.1.302'
**BUILD_SCRIPT_DEPS**
}
}
repositories {
maven { url 'https://developer.huawei.com/repo/' }
}
}

2. Add the following code to the app-level LauncherTmeplate.gradle file in the Assets\Plugins\Android directory:

apply plugin: 'com.android.application'
apply plugin: 'com.huawei.agconnect'
apply plugin: 'com.huawei.agconnect.apms'

dependencies {
implementation project(':unityLibrary')
implementation 'com.huawei.agconnect:agconnect-apms:1.4.1.303'
}

3. Configure the manifest file.

3. Packaging and Testing

Package the APK file and launch the app. Check whether the corresponding APMS logs are generated.

If so, you have integrated the APM service successfully.

For details, visit: https://forums.developer.huawei.com/forumPortal/en/topic/0203396636080560050?fid=0101188387844930001

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, please check:

AppGallery Connect APM development guide:

https://developer.huawei.com/consum...pGallery-connect-Guides/agc-apms-introduction

Unity documentation about APM:

https://docs.unity.cn/cn/Packages-cn/com.unity.hms@1.3/manual/apm.html

Coding-free Integration of AppGallery Connect APM on Android Platform:

https://forums.developer.huawei.com/forumPortal/en/topic/0203396636080560050?fid=0101188387844930001

HUAWEI AppGallery Connect APM codelab for Android:

https://developer.huawei.com/consumer/en/codelab/AppGalleryConnectAPM/index.html#0