Background introduction
Huawei Game Service SDK provides multiple capabilities such as game application self-upgrade detection, player information acquisition, game buoys, anti-addiction, achievements, leaderboards, etc. Unity provides HMS to facilitate global developers to quickly integrate these capabilities and release Huawei channels. Core App Services SDK and demo.
This post will test the water first and try the capabilities of this SDK.
Goal: Run the game demo provided by Unity, and be able to debug through basic functional interfaces, such as init and login with HUAWEI ID. If you have not installed Unity yet or have questions about Unity packaging, please refer to Unity Editor Installation and Apk Packaging: https://developer.huawei.com/consumer/cn/forum/topic/0204405811539110247?fid=18。
Document link
https://docs.unity.cn/cn/Packages-cn/[email protected]/manual/appgalleryChinese.html
Demo download path
https://github.com/Unity-Technologies/HMSSDKSample
The demo we need to run is this:
Preparation before operation
Step 1: Register as a Huawei developer and create an application.
This step will not be repeated, please refer to Huawei official documents:https://developer.huawei.com/consumer/cn/doc/development/AppGallery-connect-Guides/appgallerykit-preparation-game
I created it as follows:
Step 2: Download the agconnect-services.json file from Huawei background
- After creating the application, switch the project associated with the application, the interface will have the following prompt, here I chose "Manually enter the package name"
- Download the agconnect-services.json file
Step 3: Replace the json file in the demo provided by Unity.
Replace the json file downloaded in step 2 with the following file.
Step 4: Configure the following files in Assets/Plugins/Android.
Here, we refer to the following chapters of the documents provided by the unity official website to complete the relevant configuration, and will not repeat them.
Use Unity Editor to open the demo
By default, you have installed the Unity Editor normally. If you have not installed it, please install it yourself. I am here to refer to the Unity Hub and the 2020.1.2f1c1 version of Unity Editor installed by referring to the following post.
https://developer.huawei.com/consumer/cn/forum/topic/0204405811539110247?fid=18
Step 1: Open Unity Hub and add the project provided by Unity
The results are as follows:
Note: When opening, pay attention to selecting the correct Unity version.
Step 2: Double-click the above item to enter the Unity Editor interface.
No need to pay attention to this prompt, because the version number of the Editor that I installed locally is different from the version of the editor used by Unity for this demo, select "Continue".
Select "Continue" and wait for the project to be imported.
Finally, successfully enter the Editor, the interface is as follows:
Complete the Android Build Settings settings.
Step 1: Select "File> Build Settings"
Step 2: Select the following, click "Player Settings" to enter the project settings page.
Note: Users who have not installed the Android module need to install the Android module in the editor according to the instructions. After installing the Android module, you need to restart the editor to take effect.
Step 3: Replace your own application information according to the application information you created on the Huawei AGC platform, including package name, version number, etc.
Step 4: Refer to the following steps to generate your own application signature file.
Note: If the JDK path does not exist or is empty, please go to Preference->External Tools to modify the default JDK path. The system will automatically detect, if not detected, please install it yourself and restart the editor to try again. Refer to the video JDK not found Unity | java development kit is not set or invalid unity.
I have placed the generated signature file here, and it has been successfully generated here.
Generate and configure signing certificate fingerprint
Use the above signature file, refer to Huawei's document to generate the fingerprint of the signature certificate and configure the fingerprint in the Huawei AGC system.
Package Run Program
Step 1: Select "Switch Platform" to switch platform to Android phone.
Step 2: Select "Build And Run" and select the signature file just now.
The interface will prompt as follows:
Seeing this prompt means that the launcherTemplate.gradle file under my project Assets\Plugins\Android uses a deprecated method. To solve this problem, I can manually delete the "useProguard" in this file. Here I chose to delete manually, and delete the two lines marked in red below.
Repackage and run, the demo has been normally installed on the phone.
Step 3: Check whether the packaged demo is normal.
After packaging, the demo runs as follows.
Click the log information on the init interface to indicate success.
Click the Login>login button to open the HUAWEI ID login interface normally.
So far, it shows that the demo has been successfully run. We can check Unity's interface call method on the demo in the following file, and continue to debug and run the relevant Huawei interfaces.
Note: If you click the Login>login button to log in and fail and error 6003 is reported, please refer to Error 6003 when calling the HMS SDK interface . The most likely reason is that the signature fingerprint has changed after the signature file build is selected.
For more details, please see:
Unity Editor installation and Apk packaging:https://developer.huawei.com/consumer/cn/forum/topic/0204405811539110247?fid=18
Original link:https://developer.huawei.com/consumer/cn/forum/topic/0201418722921820534?fid=18
Author: Mayism