Before app development, configure the app information in AppGallery Connect.
Before developing an app, you will need to register as a HUAWEI developer and complete identity verification on the HUAWEI Developer website. For details, please refer to Account Registration and Verification.
Create an app by referring to Creating a Project and Creating an App in the Project. Special configurations for a game app are as follows:
Platform: Select Android.
Device: Select Mobile phone.
App category: Select Game.
A signing certificate fingerprint is used to verify the authenticity of an app, when the app attempts to access the HMS Core(APK) through HMS SDK. Before using HMS SDK, you must locally generate the signing certificate fingerprint, and configure it in AppGallery Connect.
Please ensure that the following conditions are met:
You have created the app's signature file. Signature certificate creation is a common practice, and is not detailed in this document.
The JDK has been installed on your PC.
Perform the following steps:
1. Open the command line tool (using the CMD command) and run the cd command to enter the directory where keytool.exe is located. In the following example, the Java program is installed in Program Files (x86) of drive C.
2. Run keytool -list -v -keystore <keystore-file> and follow the instructions.
In the preceding command, <keystore-file> is the complete path to the app's signature file.
Example:
- C:\Program Files (x86)\Java\jdk1.7.0_25\bin>keytool -list -v -keystore E:\HMS_SDK_3.0.0.301\Sample\HMSSdkSample_3.0.0.301_AS\HmsSample\android.keystore
3. Obtain the SHA256 fingerprint from the result.

1. Sign in to AppGallery Connect and select My projects.
2. Find your project from the project list and click the app on the project card.
3. On the Project Setting page, set SHA-256 certificate fingerprint to the SHA-256 fingerprint from Generating a Signing Certificate Fingerprint.
4. After completing configuration, click
.
Enable HUAWEI IAP for AppGalleryKit apps and games.
You are advised to enable HUAWEI Analytics Kit for AppGalleryKit app and games.
To integrate HUAWEI Game Service, enable it first.
For details, please refer to Enabling Services. If you enable the HUAWEI IAP service for the first time, you need to sign a payment agreement. For details, see Configuring IAP Service Parameters.
If you have enabled HUAWEI Analytics Kit for joint operation, enable HUAWEI Advanced Analytics Service,For details, see Enabling the HUAWEI Advanced Analytics Service.
Achievements are a great way to increase player engagement within your game, and to give the player more incentive to continue playing the game. If your app implements an achievement system, configure achievements in AppGallery Connect in advance.
Creating an achievement: To add an achievement, please refer to Adding an Achievement.
Testing an achievement: After creating an achievement, you can test it with a tester account. For details, please refer to Sandbox Testing.
Releasing an achievement: After completing the achievement test and formally putting it on the shelf, you can release it for players. For details about how to release an achievement, please refer to Releasing an Achievement. It is recommended that you avoid releasing achievements that are being tested.
Editing an achievement: You can edit the properties of an achievement before or after the achievement is formally released. For details about editing an achievement, please refer to Editing an Achievement.
Reset achievement progress: You can reset the progress of an achievement that has not been released, but can not reset that for an achievement that has been released. After progress is reset, achievement data in your tester account will be reset as well. For details, please refer to Resetting Achievement Progress.
Deleting an achievement: You can only delete an achievement that has not been released. For details, please refer to Deleting an Achievement.
The events feature allows you to collect specific data generated by your players during gameplay and store them on the Huawei game server for AppGallery Connect to use as feedback to conduct game analytics. If your app implements an event system, configure events in AppGallery Connect in advance.
Creating an event: To add an event, please refer to Adding an Event.
Editing an evebt: You can edit the properties of an event before or after the event is formally released. For details about editing an event, please refer to Editing an Event.
Releasing an event: After completing the event test and formally putting it on the shelf, you can release it for players. For details about how to release an event, please refer to Releasing an Event.
Deleting an event: You can only delete an event that has not been released. For details, please refer to Deleting an Event.
When key events about a subscription occur (e.g. successful initial subscription, successful renewal, and cancellation of subscription), Huawei payment server will send notifications to the developer server if a subscription callback address has been configured in advance. For details about how to configure the callback address, please refer to Configuring IAP Service Parameters.
If your app will be released globally, it is recommended that you configure in-app product information in AppGallery Connect in advance, so that the corresponding in-app product ID can be directly transferred to the payment interface during an interface call, without requiring you to personally manage product pricing.
To add a non-subscription, please refer to Non-Subscriptions.
To add a subscription, please refer to Subscriptions.
To configure price promotions for subscriptions, please refer to Promotional Pricing.
During app development and testing, you can test product payments with a tester account in the sandbox environment. During the testing period, when a purchase is initiated by the tester account, the Huawei payment server will identify the tester account and directly process a successful payment, without going through the payment process. For details, please refer to Sandbox Testing.
A developer can package a specified product for marketing and display the product publicity image, product name, and product description on their app details page in AppGallery (10.2.0 and later versions). For details, see Product Marketing Management.
For AndroidStudio, Huawei provides an HMS SDK that can be integrated by using the Maven repository. Before app development, you will need to integrate HMS SDK into your AndroidStudio.
1. Add the AppGallery Connect configuration file of the current app to your AndroidStudio.
a. Sign in to AppGallery Connect and select My projects.
b. Find your project from the project list and click the app on the project card.
c. On the Project Setting page, click agconnect-services.json to download the configuration file.
d. Copy the agconnect-services.json file to the app root directory.
2. Configure the Maven repository address for HMS SDK and the AppGallery Connect plug-in address.
a. Open the build.gradle file in the root directory of your AndroidStudio project.
b. Go to allprojects -> repositories and configure the Maven repository address for HMS SDK.
- allprojects {
- repositories {
- google()
- jcenter()
- maven {url 'https://developer.huawei.com/repo/'}
- }
- }
c. Go to buildscript->repositories and configure the Maven repository address for HMS SDK.
- buildscript {
- repositories {
- google()
- jcenter()
- maven {url 'https://developer.huawei.com/repo/'}
- }
- }
d. Go to buildscript->dependencies and configure the AppGallery Connect plug-in address.
- buildscript {
- dependencies {
- classpath 'com.huawei.agconnect:agcp:1.3.2.301'
- }
- }
3. Add compile dependencies.
a. Open the build.gradle file in the app directory.
b. Add the AppGallery Connect plug-in dependency to the bottom of the file.
- apply plugin: 'com.huawei.agconnect'
c. Configure compile dependencies.
- dependencies {
- implementation 'com.huawei.hms:hwid:{version}'
- implementation 'com.huawei.hms:iap:{version}'
- implementation 'com.huawei.hms:game:{version}'
- implementation 'com.huawei.hms:hianalytics:{version}'
- }
Note:
hwid indicates HUAWEI Account Kit. Replace {version} with its latest version number. For details about how to obtain the latest version number, please refer to HUAWEI Account Kit.
iap indicates HUAWEI In-App Purchases (IAP). Replace {version} with its latest version number. For details about its latest version number, please refer to HUAWEI IAP.
game indicates HUAWEI Game Service. Replace {version} with the latest version number HUAWEI Game Service.
hianalytics indicates HUAWEI Analytics Kit. Replace {version} with its latest version number. For details about how to obtain the latest version number, please refer to HUAWEI Analytics Kit.
4. Re-open the modified build.gradle file. You will find a Sync Now link in the upper right corner of the page. Click Sync Now and wait until synchronization has completed.
If an error occurs, check the network connection and the configurations in the gradle file.
5. Configure multi-language information.
Skip this step if your app does not require support from additional languages. By default, the app will support all languages supported by HMS SDK.
If your app only supports certain languages, you can configure the languages during this step.
Open the build.gradle file in the app directory of your project.
Go to android -> defaultConfig and add the resConfigs configuration. en (English) and zh-rCN (Simplified Chinese) are mandatory languages. The format is as displayed below:
- android {
- defaultConfig {
- ...
- resConfigs "en", "zh-rCN", "Other languages to be supported."
- }
- }
For details about the languages supported by HMS SDK, please refer to Languages Supported by HMS SDK.
Before starting your development in the Eclipse Integrated Development Environment (IDE), download the HMS SDK and integrate it into your app project.
1. Download and decompress the zip packages of the HMS Base SDK , HUAWEI Account SDK, HUAWEI IAP SDK and HUAWEI Game Service SDK.
For details, please refer to Eclipse SDK Download.
For details about how to integrate the Huawei Analytics service, see Integrating the Analytics Service SDK in the Eclipse Project.
2. Import all SDK projects to your workspace.
a. Go to File > Import > Android > Existing Android Code Into Workspace and click Next.

b. Click Browse and navigate to the directory where your projects are located. Select the projects to be imported under Projects and click Finish. By default, all projects are selected. You can change as needed.
NOTE: The projects to be imported must be located in the same drive as the workspace, for example, D:\. If they are not in the same drive, select Copy projects into workspace to copy the project file to the workspace.

1. Right-click your app project and choose Properties from the shortcut menu.
2. Choose Resource > Android from the navigation tree, click Add, select the imported projects, and click Apply and Close.

3. Right-click the HMSSdkAvailableUpdate project and choose Properties from the shortcut menu.
4. Choose Android from the navigation tree. Then, click Add in the Library area, select the HMSSdkUI project, and click Apply and Close.

5. As the XML file in the Eclipse IDE does not support the dollar sign ($), replace ${applicationId} in the AndroidManifest.xml file of the HMSSdkAvaliableUpdate and Agconnect-core projects with your app package name.
- <application>
- <provider
- android:name="com.huawei.agconnect.core.provider.AGConnectInitializeProvider"
- android:authorities="${applicationId}.AGCInitializeProvider"
- android:exported="false" />
- <service
- android:name="com.huawei.agconnect.core.ServiceDiscovery"
- android:exported="false" />
- </application>
Copy the properties files in the assets directory of the HMSSdkStats project to the assets directory of your app project.
NOTE: If any other kits are involved, copy the properties files of these kits to your app project directory.

Find and open the file in your project directory and add the following code to merge the manifest files in the subprojects:
- manifestmerger.enabled=true
1. Sign in to AppGallery Connect and select My projects.
2. Find your project from the project list and click the app on the project card.
3. On the Project Setting page, click agconnect-services.json to download the configuration file.
4. The Eclipse IDE does not support the AppGallery Connect plug-in. Therefore, you need to place the agconnect-services.json file in the assets directory of your project and add the following code to the Application subclass of the project. If the project does not have an Application subclass, you need to create a subclass that is inherited from the Application subclass. For example, create a MyApplication class.
- public class MyApplication extends Application{
- @Override
- public void onCreate() {
- super.onCreate();
- }
- // TODO: Add the following code:
- @Override
- protected void attachBaseContext(Context context) {
- super.attachBaseContext(context);
- AGConnectServicesConfig config = AGConnectServicesConfig.fromContext(context);
- config.overlayWith(new LazyInputStream(context) {
- public InputStream get(Context context) {
- try {
- return context.getAssets().open("agconnect-services.json");
- } catch (IOException e) {
- return null;
- }
- }
- });
- }
- // TODO: End
- }
You still need to import the following classes:
- import java.io.IOException;
- import java.io.InputStream;
- import com.huawei.agconnect.config.AGConnectServicesConfig;
- import com.huawei.agconnect.config.LazyInputStream;
- import android.app.Application;
- import android.content.Context;
- import android.util.Log;
6. Open the AndroidManifest.xml file of your project and add the Application subclass name to the application section. If the subclass name has been added, skip this step. In the following example, add the MyApplication class name.
- <application
- android:name=".MyApplication"
- ...
- >
- ...
7. In the Eclipse IDE menu bar, click Project, then Clean.
Do not obfuscate HMS SDK before compiling the APK. Otherwise, function errors may occur.
1. Open the obfuscation configuration file of your project.
2. Add configuration to ensure that HMS SDK is not obfuscated.
- -ignorewarnings
- -keepattributes *Annotation*
- -keepattributes Exceptions
- -keepattributes InnerClasses
- -keepattributes Signature
- -keepattributes SourceFile,LineNumberTable
- -keep class com.hianalytics.android.**{*;}
- -keep class com.huawei.updatesdk.**{*;}
- -keep class com.huawei.hms.**{*;}
- -keep class com.huawei.gamebox.plugin.gameservice.**{*;}
- -keep interface com.huawei.hms.analytics.type.HAEventType{*;}
- -keep interface com.huawei.hms.analytics.type.HAParamType{*;}
- -keep class com.huawei.hms.analytics.HiAnalyticsInstance{*;}
- -keep class com.huawei.hms.analytics.HiAnalytics{*;}
3. If you have used AndResGuard, add the AndResGuard allowlist to the obfuscation configuration file.
- "R.string.agc*",
- "R.string.hms*",
- "R.string.connect_server_fail_prompt_toast",
- "R.string.getting_message_fail_prompt_toast",
- "R.string.no_available_network_prompt_toast",
- "R.string.third_app_*",
- "R.layout.hms*",
- "R.drawable.upsdk*",
- "R.color.upsdk*",
- "R.dimen.upsdk*",
- "R.style.upsdk*",
- "R.id.scroll_layout",
- "R.id.divider",
- "R.id.name_textview",
- "R.id.version_textview",
- "R.id.appsize_textview",
- "R.id.allsize_textview",
- "R.id.content_textview",
- "R.id.third_app_dl_progress_text",
- "R.id.cancel_bg",
- "R.id.third_app_dl_progressbar",
- "R.id.upsdk*",
- "R.string.upsdk*",
- "R.layout.upsdk*"