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

  1. Sign in to AppGallery Connect.
  2. Click My projects.
  3. Click Add project. In the dialog box that is displayed, enter the project name, and click OK.
  4. Go to Project settings > General information, and click Add app.
  5. On the Add app page, enter the app name and package name. Select the platform, device type, app category (app or game), and language based on your needs.
  6. After your app is created, you can view the app package name and app ID in your project under My projects.

You can create a Java Maven project in IntelliJ IDEA.

  1. Open IntelliJ IDEA and go to File > New > Project to create a project.
  2. On the New Project page, click Maven, select the SDK to install, and click Next.
  3. Select a project path, and then click Finish.
  1. Open the pom.xml file of the Java Maven project and add the Maven repository address.
    <repositories> <repository> <id>sz-maven-public</id> <name>sz-maven-public</name> <url>https://developer.huawei.com/repo/</url> </repository> </repositories>
  2. Add the dependency of each SDK to the dependency element. The following uses Auth Service as an example:
    <dependencies> <dependency> <groupId>com.huawei.agconnect.server</groupId> <artifactId>agconnect-auth</artifactId> <version>1.2.0.300</version> </dependency> </dependencies>
  1. Sign in to AppGallery Connect.
  2. Click My projects, click your project, and go to Project settings > Server SDK. Click Create under API client.
  3. Click Download credential, and then add the credential file under resources of the project.
  1. In the Java project, right-click java under src/main and choose New > Package.
  2. Enter the package name, right-click the package, and choose New > Java Class to create a Java file.
  3. Add the following code to the created Java file to initialize the SDK:
    public static void initAGCClient() { try { CredentialService credential = CredentialParser.toCredential(testServerCodelab.class.getClassLoader() .getResource("agc-apiclient-xxx.json").getPath()); AGCParameter parameter = AGCParameter.builder().setCredential(credential).build(); AGCClient.initialize(parameter); System.out.println("initialize success"); } catch (AGCException e) { System.out.println("initialize Failed: " + e.getMessage()); } } public static void main(String[] args) { System.out.println("this is a demo"); initAGCClient(); }
Code copied