AppGallery Connect reads the temporary APK to obtain the app package name. Therefore, the temporary APK name must be the same as the released APK name.
This section describes the preparation procedures for integrating HUAWEI Drive Kit into your app.
The mandatory procedures include:
Register as a developer.
Create an app.
Generate a signing certificate fingerprint.
Configure the signing certificate fingerprint.
Enable HUAWEI Drive Kit.
Preparations on the client side:
Integrate the Drive SDK and HMS SDK.
Configure obfuscation scripts.
Preparations on the server side:
Integrate the HMS SDK.
Configure obfuscation scripts.
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:
l Platform: Select Android.
l Device: Select Mobile phone.
l App category: Select App.
AppGallery Connect reads the temporary APK to obtain the app package name. Therefore, the temporary APK name must be the same as the released APK name.
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:
l You have created the app's signature file.
l 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 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 that is generated from the preceding section of Generating a Signing Certificate Fingerprint.

4. After completing configuration, click
.
l To use the Drive service, you must also enable the Account and Push services.
For details, please refer to Enabling Services.
To integrate HUAWEI Drive Kit into your app, you will need to integrate both the HMS SDK and the Drive SDK. The HMS SDK provides sign-in and authentication information, while the Drive SDK provides the capability of managing users' files in Drive.
Version | Development Environment | Path |
Drive SDK4.0.3.300 | IDE: Android Studio Integration mode: Gradle + Maven | Maven repository: https://developer.huawei.com/repo/ Note: This is the link to the Maven repository, rather than the link for downloading the SDK. After downloading the SDK by using the Maven repository, integrate it into your project. For details, please refer to Integrating the Drive SDK and HMS SDK. Open source software notice: For details, please refer to the HuaweiDriveSDK 4.0.3.300 Open Source Software Notice. |
HMS SDK 4.0.1.300 | IDE: Android Studio Integration mode: Gradle + Maven | Maven repository: https://developer.huawei.com/repo/ Note: This is the link to the Maven repository, rather than the link for downloading the SDK. After downloading the SDK by using the Maven repository, integrate it into your project. For details, please refer to Integrating the Drive SDK and HMS SDK. |
If you are using Android Studio, you can integrate your Drive SDK and HMS SDK by using the Maven repository. Before you start developing an app, integrate both the Drive SDK and 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 {
- maven {url 'https://developer.huawei.com/repo/'}
- }
- }
c. Go to buildscript > repositories and configure the Maven repository address for the HMS SDK.
- buildscript{
- repositories {
- 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 AppGallery Connect plug-in dependency to the end of the file header.
- apply plugin: 'com.huawei.agconnect'
c. Configure build dependencies.
- dependencies {
- implementation 'com.huawei.hms:drive:{version}'
- implementation 'com.huawei.hms:hwid:{version}'
- implementation 'com.huawei.hms:push:{version}'
- }
Note: Replace {version} with the actual SDK version number, for example:
- implementation 'com.huawei.hms:drive:4.0.3.300'
- implementation 'com.huawei.hms:hwid:4.0.1.300'
- implementation 'com.huawei.hms:push:4.0.1.300'
4. 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 is complete.
5. Define multi-language settings.
● By default, your app supports all languages provided by the HMS SDK.If your app uses all these languages, skip the operation procedure in this section.
● If your app uses only some of these languages, follow the operation procedure in this section to complete the required configuration.
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. If your app only supports English and Simplified Chinese, the configuration is as follows:
- android {
- defaultConfig {
- ...
- resConfigs "en", "zh-rCN"
- }
- }
For details about the languages supported by the HMS SDK, please refer to Languages Supported by the HMS SDK.
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 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.**{*;}
- -keep class com.huawei.cloud.services.drive.**{*;}
3. If you have used AndResGuard, add it to the whitelist 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*"
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.
d. On the Project Setting page, click agconnect-services.json to download the configuration file.
e. 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 {
- maven {url 'https://developer.huawei.com/repo/'}
- }
- }
c. Go to buildscript > repositories and configure the Maven repository address for the HMS SDK.
- buildscript{
- repositories {
- 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 AppGallery Connect plug-in dependency to the end of the file header.
- apply plugin: 'com.huawei.agconnect'
c. Configure build dependencies.
- dependencies {
- implementation 'com.huawei.hms:hwid:{version}'
- implementation 'com.huawei.hms:push:{version}'
- }
Note: Replace {version} with the actual SDK version number, for example:
- implementation 'com.huawei.hms:hwid:4.0.1.300'
- implementation 'com.huawei.hms:push:4.0.1.300'
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.

5. Define multi-language settings.
● By default, your app supports all languages provided by the HMS SDK.If your app uses all these languages, skip the operation procedure in this section.
● If your app uses only some of these languages, follow the operation procedure in this section to complete the required configuration.
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. If your app only supports English and Simplified Chinese, the configuration is as follows:
- android {
- defaultConfig {
- ...
- resConfigs "en", "zh-rCN"
- }
- }
For details about the languages supported by the HMS SDK, please refer to Languages Supported by the HMS SDK.
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 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.**{*;}
-keep class com.huawei.cloud.base.** {*;}
-keep class com.huawei.cloud.client.** {*;}
3. If you have used AndResGuard, add it to the whitelist 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*"