Intelligent Assistant
Chat with our virtual assistant to get answers promptly.
Documents from this version have been archived, and will not continue to be maintained. Please use the latest version.
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 are as follows:
Platform: Select Android.
Device: Select Mobile phone.
App category: App or Game.
For details, see Setting Data Storage Location at the AppGallery Connect help center.

Enable HUAWEI Awareness Kit. For details, please refer to Enabling Services.
A signing certificate fingerprint is used to verify the authenticity of an app when it attempts to access an HMS Core 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 (using the cmd command) and run the cd command to go to the directory where keytool.exe is located. In the following example, the Java program is installed in Program Files (x86) in the C drive.

2. Run keytool -list -v -keystore<keystore-file> and respond as prompted.
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_2.5.1.300\Sample\HMSSdkSample_2.5.1.300_AS\HmsSample\android.keystore.jks
3. Obtain the SHA-256 fingerprint from the result.

1. Sign in toAppGallery Connect and select Myprojects.
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 that is generated from the preceding section of Generating a Signing Certificate Fingerprint.

4. After completing configuration, click
.
If you are using Android Studio, you can integrate your HMS SDK by using the Maven repository. Before you start developing an app, integrate the HMS SDK into your Android Studio first.
1. Add the AppGallery Connect configuration file of the app to your Android Studio.
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 the HMS SDK.
a. Open the build.gradle file in the root directory of your Android Studio project.

b. Go to allprojects > repositories and configure the Maven repository address for the 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 the HMS SDK.
- buildscript {
- repositories {
- google()
- jcenter()
- maven {url 'https://developer.huawei.com/repo/'}
- }
- }
d. Go to buildscript > dependencies and add dependency configurations.
- buildscript{
- dependencies {
- classpath 'com.huawei.agconnect:agcp:1.2.1.301'
- }
- }
3. Add build dependencies.
a. Open the build.gradle file in the app directory.

b. Add the following configuration to the build.gradle file:
- compileOptions {
- sourceCompatibility = 1.8
- targetCompatibility = 1.8
- }
c. Configure build dependencies under dependencies and replace {version} with the actual SDK version number, for example, implementation 'com.huawei.hms:awareness:1.0.4.301'.
- dependencies{
- implementation 'com.huawei.hms:awareness:{version}'
- }
d. Add the AppGallery Connect plug-in dependency to the file header.
- apply plugin: 'com.huawei.agconnect'
4. Open the modified build.gradle file again. You will find a Sync Now link in the upper right corner of the page. Click Sync Now and wait until synchronization is complete. If an error occurs, check the network connection and the configurations in the build.gradle file.

Before building the APK, configure obfuscation scripts to prevent the HMS SDK from being obfuscated. If obfuscation arises, the HMS SDK may not function properly.
1. Open the obfuscation script file of your Android project.
2. Add configurations to exclude the HMS SDK from obfuscation.
- -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 it to the allowlist in the obfuscation script 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*",
- "R.string.agc*"