HMS Multi Kit Integration in Unity Game Development

Huawei provides various services for developers to make ease of development and provides best user experience to end user. In this article we will be integrating HMS multiple kits like Ads kit, Game services and Analytics kit integration in Unity game development using official plugin. And by integrating in single application gives experience the ease of development and give best user experience and showcases stability of the kits how we can use kits efficiently to make user experience best of it.

Shiddalingeshwar M S
5 min readJan 15, 2021

Introduction

Huawei provides various services for developers to make ease of development and provides best user experience to end user. In this article we will be integrating HMS multiple kits like Ads kit, Game services and Analytics kit integration in Unity game development using official plugin. And by integrating in single application gives experience the ease of development and give best user experience and showcases stability of the kits how we can use kits efficiently to make user experience best of it.

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 installation package

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

3. Adding Huawei HMS AGC Services to project.

4. Generate a signing certificate.

5. Generate a SHA-256 certificate fingerprint.

To generating SHA-256 certificate fingerprint use below command

keytool -list -v -keystore D:\Unity\projects_unity\file_name.keystore -alias alias_name

6. Configure the signing certificate fingerprint.

7. Download and save the configuration file.

Add the agconnect-services.json file following dir Assets > Plugins > Android

8. Add the following plugin and dependencies in LaucherTemplate

apply plugin: ‘com.huawei.agconnect’

implementation ‘com.huawei.agconnect:agconnect-core:1.4.1.300’
implementation ‘com.huawei.hms:base:5.0.0.301’
implementation ‘com.huawei.hms:hwid:5.0.3.301’
implementation ‘com.huawei.hms:game:5.0.1.302’
implementation ‘com.huawei.hms:hianalytics:5.0.3.300’

9. Add the following dependencies in MainTemplate.

implementation ‘com.huawei.agconnect:agconnect-core:1.4.1.300’
implementation ‘com.huawei.hms:base:5.0.0.301’
implementation ‘com.huawei.hms:hwid:5.0.3.301’
implementation ‘com.huawei.hms:game:5.0.1.302’
implementation ‘com.huawei.hms:hianalytics:5.0.3.300’
implementation ‘com.huawei.hms:ads-lite:13.4.29.303’
implementation ‘com.huawei.hms:ads-consent:3.4.30.301’

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

maven { url ‘https://developer.huawei.com/repo/' }
classpath ‘com.huawei.agconnect:agcp:1.2.1.301’

11. Add Achievement details in AGC > My apps

12. Add LeaderBoard details.

13. Add Events list.

14. Create Empty Game object rename to GameManager, UI canvas texts & write assign onclick events to respective text as shown below.

15. To build apk and run in device File > Build Settings > Build for apk or Build and Run for run on connected device.

16. Result.

Tips and Tricks

  • Add agconnect-services.json file without fail.
  • Add SHA-256 fingerprint without fail.
  • Add Achievements and LeaderBoard details before run.
  • Make sure dependencies added in build files.

Conclusion

In this article, we have learnt integration of HMS GameService Kit, Ads Kit and Analytics kit in Unity based game.

Error code while fetching Player extra information and Event begin & end.

7006: The account has not been registered in the Chinese mainland. In this case, perform bypass and no further action is required.

Thanks for reading,Please do like and comment your queries/suggestions.

References

Hms game services

HMS Ads Kit

HMS Analytics Kit

--

--