Android | Integrating Your Apps With Huawei HMS Core

Ibrahim R. Serpici
Huawei Developers
Published in
5 min readMar 19, 2020

In this article, I will explain how you can integrate Huawei Mobile Services. Integrating Huawei Mobile Services (HMS) is a prerequisite for using all the kits Huawei is offering in your application.

Integration

1. Create an App in AppGallery Connect

1.1 - Sign In/Register to Huawei Developer website and click to Console

Developer console

1.2 - Click to the AppGallery Connect button in order to access AppGallery connect.

AppGallery Connect

1.3.1 - Click My projects button to create new project or add new app to existing your projects.

My apps

1.3.1.1 Create new project

Create New Project

1.3.1.2 Click Add App button to add new application to your project.

Project Settings

1.3.2 Or click My apps button to create/modify/view all of your applications

My apps

1.3.2.1 Click on New app button to create new application.

Creating new app

1.4 -Adding a new app

Enter name, category and default language for your application, then click create button to finish app creation.

New app settings

1.5 - If the app creation is successful the page will navigate you to the App Information page. On this page, you can find your APP ID and APP SECRET of your application.

Application ID

2. Add Package Name

2.1- After completing the steps above you should go to the Develop tab on the page. If you are opening Develop tab first time, it will ask you to enter your package name. You have two options here. You can either write your package name manually (Package name must be same with your project) or you can upload your apk and the system will fetch the package name automatically. For this tutorial we are going to use manual section.

Package name

3. Creating a Signing Certificate (Keystore)

Android requires that all apps be digitally signed with a certificate before they can be installed. Android uses this certificate to identify the author of an app. So you need to generate your certificate after completing the steps above.

If you don’t know how to generate Signing Certificate (Keystore) for your application please click here to go related article.

4. Generating SHA-256 Fingerpring from Signing Certificate (Keystore)

After completing the steps above, you should extract SHA-256 fingerprint with using keytool provided by JDK.

If you don’t know how to generate SHA-256 fingerprint please click here to go related article.

5. Add SHA-256 Fingerprint to the AppGallery Connect

After generating your SHA-256 fingerprint, you need to add your fingerpring to the AppGallery Connect by navigating to the bottom of Develop tab in AppGallery Connect and you will find “App Information” section. At the end of this section you will find a field named “SHA-256 certificate fingerprint:” and you should add your fingerprint there.

SHA-256 fingerprint setting

6. Add HUAWEI Maven Repository and AGCP Plugin to Project

6.1- Add HUAWEI agcp plugin and HUAWEI Maven repository to the project-level(root-level) build.gradle file

Project level build.gradle.file
Project Level Gradle File

6.2- To your module (app-level) build.gradle file (usually app/build.gradle), add the HUAWEI agconnect plugin.

App level build.gradle file

7. Configure Project Signature

7.1- Copy the generated signature file test.jks into the app folder and open your module (app-level) build.gradle file (usually app/build.gradle).

Signature .jks file

7.2- Add the signature configuration to the app-level build.gradle file

build.gradle(app)
App Level Gradle File

7.3- Synchronize your project

If the synchronization successfully completed, everything is ready and now you can use awesome kits Huawei is offering.

8. Add AppGallery Connect Json to Your Project

After finishing all the steps above, “agconnect-services.json” file needs to be downloaded from developer.huawei.com and this downloaded json file needs to be moved to the under “app” folder of your project.

Download agconnect-services.json file
Adding agconnect-services.json to your project

If you are reading this line and completed the steps above, congratulations you have successfully implemented HMS Core to your project.

Related Documentation

Codelab for HMS Integration

--

--