com.github.triplet.gradle:play-publisher 1.1.4

Gradle Plugin to upload release APKs to the Google Play Store

Homepage: https://github.com/Triple-T/gradle-play-publisher

Platform: Maven

Language: Groovy

License: MIT

View on registry: http://search.maven.org/#artifactdetails%7Ccom.github.triplet.gradl...


gradle-play-publisher

Gradle plugin to upload your APK and app details to the Google Play Store. Needs the com.android.application plugin applied. Supports the Android Application Plugin as of version 1.0.0.

Build Status

Quick Start Guide

  1. Upload the first version of your APK using the web interface.
  2. Create a Google Play Service Account (see Prerequisites).
  3. Assign a valid signingConfig to your release build type.
  4. Add the plugin to your buildscript dependencies (see Usage).
  5. Apply the plugin (see Usage).
  6. Apply your credentials inside the play block (see Credentials).

Prerequisites

Initial Play Store Upload

The first APK of your App needs to be uploaded via the web interface. This is to register the application id and cannot be done using the Play Developer API. For all subsequent uploads and changes this plugin can be used.

Google Play Service Account

To use the publisher plugin you have to create a service account for your existing Google Play Account. See https://developers.google.com/android-publisher/getting_started for more information.

Due to the way the Google Play Publisher API works, you have to grant at least the following permissions to that service account:

permissions.png

Once you finished the setup you have a so called service account email address and a p12 key file that we will use later on.

Signing Configuration

Please make sure to assign a valid signing configuration to your release build type. Otherwise, there won't be a publishable (signed) APK. In that case, the plugin won't create any of its tasks.

Usage

Add it to your buildscript dependencies:

buildscript {

    repositories {
        mavenCentral()
    }

    dependencies {
        // ...
        classpath 'com.github.triplet.gradle:play-publisher:1.1.5'
    }
}

Apply it:

apply plugin: 'com.github.triplet.play'

The plugin creates the following tasks for you:

  • publishApkRelease - Uploads the APK and the summary of recent changes.
  • publishListingRelease - Uploads the descriptions and images for the Play Store listing.
  • publishRelease - Uploads everything.
  • bootstrapReleasePlayResources - Fetches all existing data from the Play Store to bootstrap the required files and folders.

Make sure to set a valid signingConfig for the release build type. Otherwise, there won't be a publishable APK and the above tasks won't be available.

In case you are using product flavors you will get one of the above tasks for every flavor. E.g. publishApkPaidRelease or publishListingPaidRelease.

Configuration

Once you have applied this plugin to your android application project you can configure it via the play block.

Credentials

Drop in your service account email address and the p12 key file you generated in the API Console here.

play {
    serviceAccountEmail = 'your-service-account-email'
    pk12File = file('key.p12')
}

or drop in the JSON file you generated in the API Console.

play {
    jsonFile = file('keys.json')
}

Play Store Metadata

You can also update the Play Store Metadata automatically along with your APK.

To use this feature, create a special source folder called play. Inside of it, create a folder for each locale you want to support. Then drop your summary of recent changes into a file called whatsnew. The title, the description, the short description and the YouTube video url go into their own files in a subfolder called listing. App details like contact email or the default language have their own files right inside the play folder as those details are not translated. Once set up, your project should look something like this:

- [src]
  |
  + - [main]
      |
      + - [play]
          |
          + - [en-US]
          |   |
          |   + - [listing]
          |   |   |
          |   |   + - fulldescription
          |   |   |
          |   |   + - shortdescription
          |   |   |
          |   |   + - title
          |   |   |
          |   |   + - video
          |   |
          |   + - whatsnew
          |
          + - [de-DE]
          |   |
          |   + - [listing]
          |   |   |
          |   |   + - fulldescription
          |   |   |
          |   |   + - shortdescription
          |   |   |
          |   |   + - title
          |   |   |
          |   |   + - video
          |   |
          |   + - whatsnew
          |
          + - contactEmail
          |
          + - contactPhone
          |
          + - contactWebsite
          |
          + - defaultLanguage

Note: You can provide different texts for different locales, build types and product flavors. You may even support additional locales for some build types or product flavors.

Text requirements

To make sure your texts comply to the requirements of the Play Store, there is a check build-in that causes the build to fail if your text will exceed the allowed lengths.

The limits are:

  • Title: 30 characters
  • Short description: 80 characters
  • Long description: 4000 characters
  • Recent changes : 500 characters

To prevent this check for some reason, you can toggle it with the errorOnSizeLimit property:

play {
    // ...
    errorOnSizeLimit = false
}

Specify the track

As a default your APK is published to the alpha track and you can promote it to beta or production manually. If you want to directly publish to another track you can specify it via the track property:

play {
    // ...
    track = 'production' // or 'rollout' or 'beta' or 'alpha'
    userFraction = 0.2 // only necessary for 'rollout', in this case default is 0.1 (10% of the target)
}

It is also possible to provide a separate summary of recent changes for each track. Just drop in a special whatsnew-alpha text file alongside your main whatsnew file and that one will be used if you publish to the alpha track.

When defining the track as (staged) rollout you can also define a userFraction which is the portion of users who should get the staged rollout version of the APK.

Untrack conflicting versions

Only available in version 1.2.0-beta1

The Google Play Developer API does not allow us to publish a beta version if there is an alpha version with a lower version code. If you want to publish to another higher track and automatically disable from another track, this can be specified by setting the untrackOld property to true.

play {
    // ...
    track = 'beta'
    untrackOld = true // will untrack 'alpha' while upload to 'beta'
}

This will untrack whatever versions are currently blocking the publishing process. That is: every APK with a version lower than the one being uploaded in any of the tracks lower than specified by track.

Example: Publishing an APK with version 42 to production will untrack versions 41 and lower from alpha and beta. It will not, however untrack versions 43 or higher from those channels because they do not conflict.

Setting that flag to false or not setting it at all will stop the publishing process in case of conflicts. Keep that behaviour if you want to manually untrack conflicting versions rather than doing automatic untracking.

Upload Images

To speed things up a little, images are only uploaded if you explicitly say so:

play {
    // ...
    uploadImages = true
}

In that case the plugin looks for the Play Store images in your play folder. So just drop all your images into a folder structure similar to:

- [src]
  |
  + - [main]
      |
      + - [play]
          |
          + - [en-US]
              |
              + - [listing]
                  |
                  + - [featureGraphic]
                  |
                  + - [icon]
                  |
                  + - [phoneScreenshots]
                  |
                  + - [promoGraphic]
                  |
                  + - [sevenInchScreenshots]
                  |
                  + - [tenInchScreenshots]
                  |
                  + - [tvBanner]
                  |
                  + - [tvScreenshots]
                  |
                  + - [wearScreenshots]

Note: The plugin does not enforce the correct size and file type. If you try to upload invalid files, the Google API will fail with a detailed error message.

Note: The plugin copies and merges the contents of the different play folders into a build folder for upload. If there are still images left from a previous build, this might lead to undesired behaviour. Please make sure to always do a ./gradlew clean whenever you rename or delete images in those directories.

Advanced Topics

Run custom tasks before publishing

Sometimes it's required to execute some custom tasks right before executing tasks from the play plugin.

For example, one can have necessity to download images for the store listing from a remote 3rd-party server. This should happen before executing the generateReleasePlayResources task which is responsible for collecting all the play store assets for upload.

Let's assume we have a task called loadStoreListingFromRemote that fetches store listing information from a remote server and places it under src/main/play as needed by the play plugin. Our generateReleasePlayResources task should now depend on that other task. In order to do that, we have to add the follwing lines to our build script:

project.afterEvaluate {
    def generateReleasePlayResources = project.tasks.getByName("generateReleasePlayResources")
    generateReleasePlayResources.dependsOn loadStoreListingFromRemote
}

Note that we have to wait for the evaluation phase to complete before the generateReleasePlayResources task becomes visible.

Releases

  • 1.1.4 - October 14, 2015 19:56
  • 1.1.3 - September 01, 2015 18:16
  • 1.1.2 - July 16, 2015 15:55
  • 1.1.1 - July 11, 2015 14:58
  • 1.1.0 - May 10, 2015 10:46
  • 1.0.4 - April 14, 2015 17:20
  • 1.0.3 - April 13, 2015 19:08
  • 1.0.2 - February 15, 2015 15:24
  • 1.0.1 - February 06, 2015 16:21
  • 1.0.0 - January 07, 2015 16:00
See all 16 releases

Project Statistics

SourceRank 13
Dependent repositories 0
Total releases 16
Latest release
First release
Stars 1.48K
Forks 117
Watchers 51
Contributors 15
Repo Size: 346 KB

Top Contributors See all

Björn Hurling Christian Becker Markus Pöschl Shiraji Zac Sweers Sven Bendel minakov Andrea Baccega Roc Boronat AlexTrotsenko Kirill Rakhman chrissd23 Martin d'Allens Nikolay Rudenko Falko Richter

Something wrong with this page? Make a suggestion

Export .ABOUT file for this library

Last synced: 2016-07-18 13:15:16 UTC

Login to resync this project