On the AppGallery Connect (AGC) console of HUAWEI Developer, create a project and an app.

  1. Sign in to HUAWEI Developer and click Console.
  2. Click the AppGallery Connect card and access AppGallery Connect console.
  3. On the AppGallery Connect console, click My Projects.
  4. On the displayed Project Management page, click "+ Add project".
  5. On the New project page, enter the project name and click OK.
  6. On the General information tab page, click Add App.
  7. On the Add App page, select the Platform and Device, enter the App name and Package name, and select the App category (App or Game) and Default language.
  8. After the application is created, the application information page is displayed. On this page, you can view the APP ID and SecretKey allocated by the system to the application.

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

  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 application information page of the project, click to add the SHA256 certificate fingerprint.
  2. Enter the generated SHA256 value in the text box.
  3. Click √ to save the fingerprint.

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

  1. On the app information page of the project, click the Manage APIs tab.
  2. On the Manage APIs tab page, select the service to be enabled.
  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 { // ... }
  3. Download the agconnect-services.json file from AppGallery Connect.
  4. Place the agconnect-services.json file in the app directory of your app.
  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