Intermediate: HMS Multi Kit Integration in Unity Game Development — part 1

Lokesh Suryan
4 min readMar 19, 2021

--

Introduction

Huawei provides various services for developers to make ease of development and provides best user experience to end users. In this article, we will be integrating following kits:

  • Ads Kit
  • Push Kit
  • Analytics Kit
  • Game services
  • Location kit

We will learn how to integrate above HMS Kits in Unity game development using official plugin.

This application will be explained in two parts:

1. In part one, I will explain how to integrate Ads Kit, Analytics kit and Push Kit.

2. In part two, I will explain how to integrate Game services and Location Kit.

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.

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

9. Open AndroidManifest file and add below permissions.

11. Open “mainTemplate.gradle” and add dependencies lines like shown below.

12. Create Scripts folder and create a class.

Projecttile.cs

Die.cs

AndroidMenifest.xml

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

Result

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 you have enable debug mode.

Conclusion

We have learnt integration of HMS Ads Kit, Push Kit and Analytics kit in Unity Game.

Thanks for reading the article, please do like and comment your queries or suggestions.

References

HMS Ads Kit

HMS Analytics Kit

HMS Push Kit

--

--

No responses yet