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.

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 and Package name 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 SHA-256 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 SHA-256 fingerprint by using keytool provided by the JDK and signature file.

  1. Open the command window and access the bin directory where the JDK is installed.
  2. Run the following keytool command in the bin directory and enter the password for the signature file key. This password was specified when the signature file was created.
    keytool -list -v –keystore D:\Android\WorkSpcae\HmsDemo\app\HmsDemo.jks
  3. Obtain the SHA-256 fingerprint from the result.

The developer sets the package name of the created application on the AGC.

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

Open the application level build.gradle file that created the application and mark the package name

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

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

Select Manage package, in the pop-up box, select upload

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

Select save after successful upload

During this step, you will configure the generated SHA-256 fingerprint in AppGallery Connect.

  1. In AppGallery Connect, click the app that you have created and go to Develop -> Overview.
  2. Go to the App information section and enter the SHA-256 fingerprint that has been generated.
  3. Click √ to save the fingerprint.
  4. 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
  2. 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.0.1.301' // 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 // ... } }
  3. In your module (app-level) build.gradle file (usually app/build.gradle), add a line to the bottom of the file.
  4. apply plugin: 'com.android.application' android { // ... } dependencies { // ... } // Add the following line to the bottom of the file: apply plugin: 'com.huawei.agconnect' // HUAWEI agconnect Gradle plugin
  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 the signature configuration in the android directory of 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