An education of my own

Freire explains the relationship between practice theory and knowledge need each other. “Without practice there’s knowledge” (pg, 97). This quote states that there is a correlation between the two…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




HMS Unity integration for Analytics kit and Crash Services

Hello everyone,

In this article we are going to create Unity project and explain how to implement HMS Analytics kit and Crash Services.

By integrating the HMS Core Analytics SDK, you can:

HUAWEI Analytics Kit identifies users and collects statistics on users by an anonymous application identifier (AAID). The AAID is reset in the following scenarios:

1) Uninstall or reinstall the app.

2) The user clears the app data.

After the AAID is reset, the user will be counted as a new user.

There are 3 types of events: Automatically collected, predefined, and custom.

After you integrate the Crash SDK into your app, it will be automatically initialized when your app is launched. When an app crash occurs, the SDK will report the crash information to HUAWEI Analytics. A readable report will be generated in about 5–10 minutes, helping you quickly detect, locate, and rectify the problem.

Crash Service workflow

Please check HMS Unity plugin integration details below:

Enable Analytics Service

1- Download HMS Unity Plugin.

2- Import the Plugin to your Unity project

3- Configure AndroidManifest file

4- Add configuration (agconnect-service.json) file

5- Use AnalyticsManager prefabs

We have a two option for downloading we can download latest package or latest codes. In this article we will use latest package.

Latest Package

Optional - Latest Codes

Latest Codes

Import package to unity.

Asset Folder

Download configuration file from AGC

My Project >> Project Setting >> General Information >> App Information

agconnect-services.json

My Project >> Project Setting >> General Information >> Project Information

5- Use AnalyticsManager prefabs

Drag and drop Analytics Manager prefabs to your project.

AnalyticsManager Prefabs

Analytics Manager prefabs has two manager scripts they will be initilize your Analytics and Crash services.

Do not change Prefabs names, because in code we are calling instance of prefabs object by their name.

Project settings configuration:

Build Setting >> Player Setting >> Project Settings

Other Settings

Publish Setting

In plugin we have demo scene for Analytics kit and Crash services. Upper side of the scene is for Analytics kit, down side of the scene for Crash services.

Send Event button connectted to “AnalyticsDemoManager.SendEvet”.

Event ID, Key and Value should not be empty or null.

Analytics Controller Script will get datas from scene.

Plugin sdk also is open source, if you want you can add new features there.

Crash button directly invoke “CrashManager” scripts, just enabling crash services is enough to collect crash logs.

We have filled the scene for analytics event then we have clicked Send Event button.

Game Scene

We can check result simultaneously on AppGallert Connect.

Down side of Real-time overview page we can see our event.

Event Analysis

Crash kit testing results:

Click >> Enable Crash button.It will collect crash logs.

Crash Game >> Test it button. Game will be crash.

Logcat result:

AGC Crash Result:

Click the Statistics tab and add filters or select a period in the upper right corner to filter crash data based on your needs. For example, if you triggered crashes on multiple devices to test the Crash service in the last 24 hours, you can select Last 24 hours in the upper right corner to check whether the crash data was reported.

AGC Crash Page

After confirming that crash data exists, click the Problems tab and select a period in the upper corner to check the crashes that took place during the period. For example, you can select Last 24 hours if your app crashed in the last 24 hours. Based on the crash time and quantity, you can find the specific crash. As shown in the following figure, java.lang.Error is the crash triggered during Crash service testing.

On the crash details page, analyze the crash trend based on the chart and view the cause of the crash on the Stack tab page. Below image show cause of the crash.

We crash application with Unity function : `Application.ForceCrash(0)`

Querying Crash Information by Custom Key-Value Pair

Huawei Analytics Gradle Dependency

Check your libraries from “Assets\Plugins\Android”, if dependency not there you should add for Analytics kit. In plugin we add libraries with statics way. We can can use gradle approach also.

Analytics kit 5.0.3.300 dependencies

Thank you for reading this article.

I hope this gives you a starting point for Huawei Mobile Services and Unity integration.

Add a comment

Related posts:

21 Odd Habits of Medium Writers

You write on Medium which makes you part of an exclusive group of writers on the internet. You’re here to express yourself, try to make some money on the platform and connect with other readers. Your…

1972 Pontiac Lemans Is Freshly Restored

Loaded with miles of style and a big V8, driving this 1972 Pontiac Lemans is a way to make a strong statement everywhere you go. This car is a celebration of American optimism at a time when there…