Automate publishing App Bundle or APK to Google Play Store

This blog post shows how to automate publishing to Google Play Store with Gradle Play Publisher. The goal is to automate the manual process of uploading Apk andBundle files, and also release notes to the Google Play Store. First time publishing the APK it’s a manual process.

Publish App Bundle:

GOOGLE_ACCOUNT_SERVICE_FILE=/home/gradle/TuneIn/Tunein-Android-Play-Publish.json

(don’t check in file key to Github add it to .gitignore, or add the key file at build time).

2. Add below code snippet to build.gradle (app). More details here (note below code needs to go on the top of the file).

plugins {
id 'com.android.application'
id 'com.github.triplet.play' version '2.1.0'
}

3. Also, add below code to build.gradle (app). The configuration below uploads APK or Bundle files to the Internal test track.

android {
....
play {
track = 'internal' //'alpha','beta' or 'production'
serviceAccountEmail = "myapp-release@api-75.gserviceaccount.com"
serviceAccountCredentials = file(p12_KEY)
}
...
}

4. Configuration is done, now to publish Bundle or APK to Google Play Store using below commands:

Publish App Bundle

./gradlew publishBundle

Publish APK:

./gradlew publishApk

Note: remember to update your App Version code or you will get publish error:

* What went wrong:
Execution failed for task ':app:publishReleaseBundle'.
> Version code 45 is too low for variant release.

Publish App Bundle and Release notes:

  1. Add your release notes in default.txt.
  2. To publish Bundle and the release notes we use the same command that we use to upload Bundle.

Publish App Bundle and Release notes:

./gradlew publishBundle

Production rollout by percentage

android {

play {
track = "production"
userFraction = 0.5 //case default is 0.1 (10% of the target)
releaseStatus = "inProgress"

serviceAccountEmail = "mympp471651.iam.gserviceaccount.com"
serviceAccountCredentials = file(p12_KEY)

}

Check GPP configuration:

Ping me if you have any questions. Thanks for reading!

software engineer, read, swim, travel. apps: https://goo.gl/rDuuQw https://goo.gl/15GvfE

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store