[Huawei Developers] shikkerimath:
Introduction

Huawei AppGallery Connect provides Application Performance Management (APM) service provides app performance monitoring capabilities. You can view the analyse app performance data collected by APM in AG Console, this helps to understand the app performance quickly and accurately in real time to rectify app performance problems and continuously improve user experience.

View attachment 5250423

Development Overview

You need to install Unity software and I assume that you have prior knowledge about the unity and C#.

Hardware Requirements

A computer (desktop or laptop) running Windows 10.

A Huawei phone (with the USB cable), which is used for debugging.

Software Requirements

Java JDK 1.7 or later.

Unity software installed.

Visual Studio/Code installed.

HMS Core (APK) 4.X or later.

Integration Preparations

1. Create a project in AppGallery Connect.

2. Create Unity project.

View attachment 5250425

3. Huawei HMS AGC Services to project.

View attachment 5250427

4. Download and save the configuration file.

Add the agconnect-services.json file following directory Assests > Plugins > Android

View attachment 5250431

5. Add the following plugin and dependencies in LaucherTemplate.

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

implementation 'com.huawei.agconnect:agconnect-core:1.4.2.301'
implementation 'com.huawei.agconnect:agconnect-apms:1.4.1.303'

6. Add dependencies in build script repositories and all project repositories and class path in BaseProjectTemplate.

maven { url 'https://developer.huawei.com/repo/' }

classpath 'com.huawei.agconnect:agconnect-apms-plugin:1.4.1.303'
classpath 'com.huawei.agconnect:agcp:1.4.2.301'

7 Create Empty Game object rename to GameManager, UI canvas texts and button and assign onclick events to respective text and button as shown below.

View attachment 5250433

View attachment 5250435

8. Click to Build apk, choose File > Build settings > Build to Build and Run, choose File > Build settings > Build And Run.

View attachment 5250437

GameManager.cs

using System.Diagnostics;
using UnityEngine;
using Debug = UnityEngine.Debug;
using HuaweiService.apm;
public class GameManager : MonoBehaviour
{
CustomTrace customTrace;
void Start()
{
customTrace = APMS.getInstance().createCustomTrace("testTrace");
}
public void onClickButton(){

customTrace.start();
Debug.Log ("Hello" + " world");
UnityEngine.Debug.Log("CustomTraceMeasureTest start");
customTrace.putMeasure("ProcessingTimes", 0);
for (int i = 0; i < 155; i++) {
customTrace.incrementMeasure("ProcessingTimes", 1);
}
long value = customTrace.getMeasure("ProcessingTimes");
Debug.Log("Measurename: ProcessingTimes, value: "+ value);
UnityEngine.Debug.Log("CustomTraceMeasureTest success");

}
}

Result

To view AppGallery Connect analysis choose Quality > APM

View attachment 5250439

View attachment 5250441

View attachment 5250443

View attachment 5250445

View attachment 5250447

View attachment 5250449

View attachment 5250451

View attachment 5250453

View attachment 5250463

View attachment 5250465

Tips and Tricks

Add agconnect-services.json file without fail.

Make sure dependencies added in build files.

Make sure that you that APM Service enabled.

Conclusion

In this article, we have learnt integration of Huawei Application Performance Management (APM) Service into Unity Game development using official plugin. Conclusion is APM helps us to rectify quickly and accurately app performance and continuously improve user experience.

Thank you so much for reading article, I hope this article helps you.

Reference

Unity Manual

Service Introduction official documentation

Checkout in forum