You can create an app in AppGallery Connect. Then AppGallery Connect will automatically generate basic configurations for it.

  1. Sign in to AppGallery Connect.
  2. Click My projects.
  3. Go to Project settings > General information. On the page displayed, click Add app.
  4. On the Add app page, specify the app name, package name, platform, device, app category, and default language. Here, set Platform to HarmonyOS.
  5. Check the app package name and app ID in your project under My projects.

You will create an app using Android Studio. During the creation, you will need to use the app name that you have specified in AppGallery Connect.

  1. Open DevEco Studio and go to File > New > New Project to create a project.
  2. On the Choose your ability template page, select Empty Ability(Java) and then click Next.
  3. On the Configure your project page, set Project Type to Application, enter the app name (which must be the same as that specified in AppGallery Connect), package name (which must be the same as that created in AppGallery Connect), Save Location, and Compatible API Version, and then click Finish to complete app creation.
  1. Add dependencies to the project-level build.gradle file of DevEco Studio, including the Maven repository address and AppGallery Connect plugin address.
    buildscript { repositories { maven { url 'https://repo.huaweicloud.com/repository/maven/' } maven { url 'https://developer.huawei.com/repo/' } jcenter() } dependencies { classpath 'com.huawei.ohos:hap:2.4.4.2' classpath 'com.huawei.ohos:decctest:1.2.4.0' classpath 'com.huawei.agconnect:agcp-harmony:1.1.0.300' } } allprojects { repositories { maven { url 'https://repo.huaweicloud.com/repository/maven/' } maven { url 'https://developer.huawei.com/repo/' } jcenter() } }
  2. Open the app-level build.gradle file and add com.huawei.agconnect on the line below com.huawei.ohos.hap.
    apply plugin: 'com.huawei.ohos.hap' apply plugin: 'com.huawei.ohos.decctest' apply plugin: 'com.huawei.agconnect' ohos { ... } dependencies { ... }
  3. Add the following configuration to module > abilities in the config.json file under entry:
    { "permissions": [ "com.huawei.agconnect.core.DataAbilityShellProvider.PROVIDER" ], "name": "com.huawei.agconnect.core.provider.AGConnectInitializeAbility", "type": "data", "uri": "dataability://${app.bundlename}.AGConnectInitializeAbility" }

    Replace ${app.bundlename} with the actual bundle name of the module in the config.json file.

  1. Click Sync Now to synchronize the project.
  2. Check whether the message "Gradle sync finished" is displayed. If so, the synchronization is successful and you have integrated the SDK to your app.
Code copied