Beginner: Huawei APP Performance Management (APM) in Unity Development
In this article, we will cover Integration of Huawei APM Kit in Unity Project using Official Plugin (Huawei HMS Core App Services). App Performance Management (APM) of HUAWEI AppGallery Connect provides minute-level app performance monitoring capabilities. You can view and analyze app performance data collected by APM in AppGallery Connect to comprehensively understand online performance of apps in real time, helping you quickly and accurately rectify app performance problems and continuously improve user experience. Performance Monitoring helps you to understand where and when the performance of your app can be improved, so that you can use information to fix performance issues.
You need to install Unity software and I assume that you have prior knowledge about the unity and C#.
- A computer (desktop or laptop) running Windows 10.
- A Huawei phone (with the USB cable), which is used for debugging.
- Java JDK installation package.
- Unity software installed.
- Visual Studio/Code installed.
- HMS Core (APK) 4.X or later.
Follows the steps.
1 Create Unity Project.
- Open unity Hub.
- Click NEW, select 3D, Project Name and Location.
- Click CREATE, as follows:
2. Click Asset Store, search Huawei HMS Core App Services and click Import, as follows.
3. Once import is successful, verify directory in Assets > Huawei HMS Core App Services path, as follows.
4. Choose Edit > Project Settings > Player and edit the required options in Publishing Settings, as follows.
5. Generate a SHA-256 certificate fingerprint.
To generating SHA-256 certificate fingerprint use below command.
6. Download agconnect-services.json and copy and paste to Assets > Plugins > Android, as follows.
7. Choose Project Settings > Player and update package name.
8. Open LauncherTemplate.gradle and add below line.
9. Open AndroidManifest file and add below permissions.
10. Open “baseProjectTemplate.gradle” and add lines, as follows.
11. Open “mainTemplate.gradle” and add lines like shown below.
12. Create Scripts folder and create a class.
13. Follow the steps, as shown in image:
- Assign APM script to Canvas.
- Select Button and add onclick event.
- Assign Button to Button handler.
14. Onclick Button Handler you find your script APMServiceManager (As per your script name) and attach method as per below screen shot.
15. To build apk and run in device, choose File > Build Settings > Build for apk or Build and Run for run on connected device.
Click on CustomTraceMeasureTest Button you can see successful toast message on your screen, now you can view and analyze app performance data collected by APM in AppGallery Connect.
Tips and Tricks
- Always use the latest version of the library.
- Add agconnect-services.json file without fail.
- Add SHA-256 fingerprint without fail.
- Make sure dependencies added in build files.
- Make sure that APM Service enabled.
In this article, we have learnt integration of Huawei Application Performance Management (APM) Service into Unity Game development using official plugin. APM helps you to understand quickly and accurately where and when the performance of your app can be improved, so that you can use information to fix performance issues.
Thanks for reading the article, please do like and comment your queries or suggestions.