Before you start developing an app, configure app information in AppGallery Connect.
Before you get started, you must register as a HUAWEI developer and complete identity verification on the HUAWEI Developer website. For details, please refer to Register a HUAWEI ID.
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: Android
Device: Mobile phone
App category: App or Game
A signing certificate fingerprint is used to verify the authenticity of an app when it attempts to access HMS Core (APK) through the HMS SDK. Before using the HMS Core, you must locally generate a 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.
The JDK has been installed on your PC.
Perform the following steps:
1. Open the command line tool and run the following command, in which<keystore-file>is the complete path to the app's signature file:
- keytool -list -v -keystore <keystore-file>
2. Obtain the SHA-256 fingerprint from the result. An example of the result is as follows:
- Alias name: <alias-name>
- Creation date: Aug 29, 2019
- Entry type: PrivateKeyEntry
- Certificate chain length: 1
- Certificate[1]:
- Owner: CN=Android Debug, OU=hua, C=zg
- Issuer: CN=Android Debug, OU=hua, C=zg
- Serial number: 1e46890c
- Valid from: Thu Aug 29 21:09:44 CST 2019 until: Mon Jan 14 21:09:44 CST 2047
- Certificate fingerprints:
- MD5: EC:29:9E:ED:18:35:E0:A0:93:EA:AD:E2:D9:4D:B7:6A
- SHA1: E6:6B:61:C9:E5:86:81:E7:3A:7A:86:11:87:FB:DD:B6:2F:72:9D:80
- SHA256: 39:B1:5E:52:70:8C:07:6D:5A:F7:0B:96:8B:D1:77:A0:8F:CA:09:08:72:90:FD:2A:1E:DB:9A:6C:2F:4E:B5:97
- Signature algorithm name: SHA256withRSA
- Subject Public Key Algorithm: 2048-bit RSA key
- Version: 3
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 fromGenerating a Signing Certificate Fingerprint.

4. After completing configuration, click
.
To download or use HUAWEI Location Kit, you must agree to the HUAWEI Developer Service Agreement, HUAWEI APIs Use Agreement, and AppGallery Connect Data Processing Addendum. You understand and undertake that downloading or using said HUAWEI Location Kit shall be deemed that you have agreed to all the preceding agreements, and you will fulfill and assume the legal responsibilities and obligations in accordance with said agreements.
For Android Studio, Huawei provides HMS SDK that can be integrated by using the Maven repository. Before app development, you will need to integrate HMS SDK into your Android Studio.
1. Add the AppGallery Connect configuration file of the current app to your AndroidStudio.
a. Sign in toAppGallery Connectand 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.
a. Open the build.gradle file in the root directory of your Android Studio project.

b. Go to allprojects > repositories and buildscript > repositories, and configure the Maven repository address for HMS SDK.
- allprojects {
- repositories {
- maven {url 'https://developer.huawei.com/repo/'}
- }
- }
- buildscript {
- repositories {
- maven {url 'https://developer.huawei.com/repo/'}
- }
- dependencies {
- classpath 'com.huawei.agconnect:agcp:1.2.1.301'
- }
- }
3. Add compile dependencies.
a. Open the build.gradle file in the app directory.

b. Configure compile dependencies.
- dependencies {
- implementation 'com.huawei.hms:location:{version}'
- }
Replace {version} with the actual SDK version number, for example:
implementation 'com.huawei.hms:location:4.0.4.300'.
c. Add the AppGallery Connect plug-in dependency to the file header.
- apply plugin: 'com.huawei.agconnect'
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.

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.
1.Downloading the SDK
Click here to download the .zip packages of the HMS Base SDK and HMS Location SDK.
Import all SDK projects to your workspace.
Decompress the hmssdk-eclipse-{version}.zip and locationsdk-eclipse-{version}.zip packages.
Go to File > Import > Android > Existing Android Code Into Workspace
and click Next.

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

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

As the XML file in the Eclipse IDE does not support the dollar sign ($), replace ${applicationId} in the AndroidManifest.xml file of the HMSSdkBase 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>
3.Copying the Properties Files to Your App Project Directory
The Eclipse IDE cannot automatically merge the assets directories. Copy the properties files in the assets directory of the subprojects to the assets directory of your project. The following table lists the properties files to be copied.
| Subproject | Properties File |
|---|---|
| HMSSdkStats | hianalytics_njjn, grs_sdk_global_route_config_opensdkService.json |
Update | updatesdkcas.bks |
Network-grs | grs_sdk_server_config.json, grs_sp.bks |
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
The ADT version must be 17 or later.
a. Open the AndroidManifest.xml file in your app project directory.

b. Configure your app ID.
Replace123456789 with the app ID that you requested from HUAWEI Developer.
- <meta-data
- android:name="com.huawei.hms.client.appid"
- android:value="123456789" />
1. Sign in to AppGallery Connect and select My apps.
2. Find your app from the list and click the app name.

3. Go to Develop>Overview>App information.
4. Click agconnect-services.json to download the configuration file.

5. 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.
The configuration file in Android Studio is proguard-rules.pro, and that in Eclipse is proguard-project.txt.
1. Open the obfuscation configuration file of your Android 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.**{*;}
3. If you have used AndResGuard, add the AndResGuard allowlist to the obfuscation configuration file.
- "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.string.upsdk_*",
- "R.layout.hms*",
- "R.layout.upsdk_*",
- "R.drawable.upsdk*",
- "R.color.upsdk*",
- "R.dimen.upsdk*",
- "R.style.upsdk*