During this step, you will create an app in AppGallery Connect (AGC) of HUAWEI Developer. When creating the app, you will need to enter the app name, app category, default language, and signing certificate fingerprint. After the app has been created, you will be able to obtain the basic configurations for the app, for example, the app ID and app secret, which will then be used in subsequent development activities.

  1. Sign in to HUAWEI Developer and click Console.
  2. Click the HUAWEI AppGallery card and access AppGallery Connect.
  3. On the AppGallery Connect page, click My apps.
  4. On the displayed My apps page, click New.
  5. Enter the App name, select App category (options: App and Game), and select Default language as needed.
  6. Upon successful app creation, the App information page will automatically display. There you can find the App ID and App secret that are assigned by the system to your app.

The developer sets the package name of the created application on the AGC . There are two ways to add the application package name.

1. Manually enter the package name

Open the previously created application in AGC application management and select the Develop TAB to pop up an entry to manually enter the package name and select manually enter the package name

Fill in the application package name in the input box and click save

2. Upload install APK file to add package name

Open the previously created application in AGC application management and select the Develop TAB. You can choose to upload the package to get the package name.

Or just click Distribute -> Release app -> Version infomation -> Draft-> Software version

Click Software packages, and then in the pop-up box, click Upload

In the pop-up upload prompt box, select the APK file generated in the create signature certificate

Click save after successful upload

During this step, you will create a new Android Studio project for your app, When creating the project, you will need to use the app name that you have specified in AppGallery Connect.

  1. Start Android Studio. On the menu bar, go to File->New->New Project...
  2. On the Choose your project page, click Empty Activity, and then click Next.
  3. On the Configure your project page, enter Name (it's the same as the input on AppGallery Connect) and Package name (it's the same as the input on AppGallery Connect) for your app, select Save location, Minimum API level, and then click Finish. You have now created a project for your app.

During this step, you will create a new signature file in Android Studio, which will be used for generating the SHA256 fingerprint for your app.

  1. In the menu bar of the Android Studio project that you have created, go to Build>Generate Signed Bundle/APK...
  2. On the Generate Signed Bundle or APK page, select APK and click Next.
  3. If you've already had a signature file, click Choose existing... , select the signature file, and specify Key store password,Key alias, and Key password for it. After completing this, click Next.
  4. If you don't have a signature file, click Create new...

    Specify relevant information including Key store path, Password, and Key Alias.

    After successfully creating the signature file, you will find the signature file information on the automatically displayed Generate Signed Bundle or APK page. Click Next.

  5. On the displayed page, select V1 and V2 next to Signature Versions, and then click Finish. You have now created a signed APK (This APK file can be used to upload the generated package name).

During this step, you will need to export the SHA256 fingerprint by using keytool provided by the JDK and signature file.

Windows OS

  1. Open the command window and access the bin directory where the JDK is installed.
  2. Run the keytool command in the bin directory to view the signature file and run the command.
    keytool -list -v -keystore D:\Android\WorkSpcae\HmsDemo\app\HmsDemo.jks
  3. Enter the password of the signature file keystore in the information area. The password is the password used to generate the signature file.
  4. Obtain the SHA256 fingerprint from the result.

Mac OS

  1. Open Terminal.
  2. On the terminal, enter keytool to view the signature file and run the command.
    keytool -list -v -keystore /Users/admin/Downloads/HmsDemo.jks
  3. Enter the password of the signature file keystore in the information area. The password is the password used to generate the signature file.
  4. Obtain the SHA256 fingerprint from the result.

During this step, you will configure the generated SHA256 fingerprint in AppGallery Connect.

  1. On the page for creating an application, click the Develop tab. or, find the created project application in My Projects and choose Project Settings -> Convention. The Convention page is displayed.
  2. Go to the App information section and Click to add the SHA256 certificate fingerprint.
  3. Enter the generated SHA256 value in the text box.
  4. Click √ to save the fingerprint.

Upon completion, the signing certificate fingerprint will take effect immediately.

  1. In Android Studio root-level (project-level) build.gradle file, add rules to include the HUAWEI agcp plugin and HUAWEI Maven repository
    buildscript { repositories { // ... // Check that you have the following line (if not, add it) maven { url 'https://developer.huawei.com/repo/' } // HUAWEI Maven repository } dependencies { // ... // Add the following line classpath 'com.huawei.agconnect:agcp:1.3.1.300' // HUAWEI agcp plugin } } allprojects { // ... repositories { // ... // Check that you have the following line (if not, add it) maven { url 'https://developer.huawei.com/repo/' } // HUAWEI Maven repository // ... } }
  2. In your module (app-level) build.gradle file (usually app/build.gradle), add a line to the bottom of the file.
    apply plugin: 'com.android.application' // Add the following line apply plugin: 'com.huawei.agconnect' // HUAWEI agconnect Gradle plugin android { // ... } dependencies { // ... }
  1. Copy the generated signature file hmsdemo.jks into the app folder and open your module (app-level) build.gradle file (usually app/build.gradle).
  2. Add signature configuration information to the android closure of the build.gradle file
    signingConfigs { release { storeFile file('HmsDemo.jks') keyAlias 'hmsdemo' keyPassword '123456' storePassword '123456' v1SigningEnabled true v2SigningEnabled true } } buildTypes { release { signingConfig signingConfigs.release minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } debug { signingConfig signingConfigs.release debuggable true } }

Click sync now to synchronize the project

Completed successfully that means successful synchronization, and the integration preparation is completed.

Code copied