Skip to content

Huawei AppGallery Connect Publishing Gradle Plugin

License

Notifications You must be signed in to change notification settings

syslogic/agconnect-publishing-gradle-plugin

Repository files navigation

Huawei AppGallery Connect Publishing Gradle Plugin

Social Media Preview

Legal Disclaimer: This product is NOT officially endorsed or certified by Huawei Technologies Co., Ltd.
The trademarks are being referenced for identification purposes only, in terms of a nominative fair use.

The official Huawei repositories can be found there: @HMS-Core.


Features

  • It automates the Huawei AppGallery Connect Publishing API.
  • It can upload and release Android APK/ABB packages.

Development

The plugin source code can be swiftly installed into any Android Gradle project with git clone:

git clone https://github.com/syslogic/agconnect-publishing-gradle-plugin.git ./buildSrc

Package Installation

Plugin io.syslogic.agconnect.publishing depends on com.android.application.

These plugins can be set up in the buildscript block of the root project's build.gradle:

buildscript {
    repositories {
        google()
        mavenCentral()
        maven { url 'https://developer.huawei.com/repo/' }
        maven { url 'https://jitpack.io' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:8.6.0'
        classpath 'com.huawei.agconnect:agcp:1.9.1.303'
        classpath 'io.syslogic:agconnect-publishing-gradle-plugin:1.3.6'
    }
}

Or in the version-catalog gradle/libs.versions.toml:

[versions]
agconnect_publishing_plugin = '1.3.6'

[plugins]
agconnect_publishing = { id = "io.syslogic.agconnect.publishing", version.ref = "agconnect_publishing_plugin" }

Then they can be applied in the module's build.gradle:

plugins {
    id 'com.android.application'
    id 'com.huawei.agconnect'
    // id 'io.syslogic.agconnect.publishing'
    alias(libs.plugins.agconnect.publishing)
}

Configuration

PublicationExtension can be configured with the following properties:

  • configFile: The path to the API client credentials file is absolute.
  • releaseType: Release Type, 1=network (default), 3=phased.
  • verbose: Verbose logging, on/off.
  • logHttp: HTTP logging, on/off.
/** Huawei AppGallery Connect: agc-apiclient.json */
def json_agc = "distribution${File.separator}agconnect_apiclient.json"
if (rootProject.file(json_agc).exists()) {
    agcPublishing {
        configFile = rootProject.file(json_agc).absolutePath
        releaseType = 1
        verbose = false
        logHttp = true
    }
}

These properties are all optional, while:

  • providing the config file at the default location: distribution/agconnect_apiclient.json.

Plugin Tasks

Gradle Plugin Tasks

Example Log Output

The log output for task :mobile:uploadReleaseAab explains what it does.
To be precise, it only uploads APK/ABB packages, but does not release them.

> Task :mobile:bundleRelease
> Task :mobile:uploadReleaseAab
> POST /api/oauth2/v1/token HTTP/1.1
> HTTP/1.1 200 OK
> GET /api/publish/v2/upload-url?appId=000000000&releaseType=1&suffix=aab HTTP/1.1
> HTTP/1.1 200 OK
> POST /FileServer/uploadFile HTTP/1.1
> HTTP/1.1 200 OK
> PUT /api/publish/v2/app-file-info?appId=000000000&releaseType=1 HTTP/1.1
> HTTP/1.1 200 OK
> GET /api/publish/v2/package/compile/status?appId=000000000&pkgIds=00000000000000000 HTTP/1.1
> HTTP/1.1 200 OK

AAB file someapp_1.0.0-huawei-release.aab has been uploaded.
13.1 MB in 14s equals a transfer-rate of 957.0 kB/s.

Note: After this, some app-information still needs to be manually completed.

The log output for task :mobile:publishReleaseAab explains what it does.
To be precise, it submits an already uploaded APK/ABB package for review.

> Task :mobile:publishReleaseAab
> POST /api/oauth2/v1/token HTTP/1.1
> HTTP/1.1 200 OK
> POST /api/publish/v2/app-submit?appId=000000000&releaseType=1 HTTP/1.1
> HTTP/1.1 200 OK
Submitted for release: org.acme.someapp (000000000).

Support

Status

Gradle CI

Release

MIT License