API to automatically upload apk to Google Play?

43,417

Solution 1

As of today there is a new official publishing API That allows you to upload to any channel (ie. alpha, beta...) or update title and description and more.

From the docs:

  • Uploading new versions of an app Releasing apps, by assigning APKs to various Tracks (alpha, beta, staged rollout, or production)
  • Creating and modifying Google Play Store listings, including
  • localized text and graphics and multi-device screenshots

Look here for more info: https://developers.google.com/android-publisher/

Solution 2

gradle-play-publisher is a Gradle plugin to upload your APK and app details to the Google Play Store.

I simply run ./gradlew publishApkRelease from my terminal and it uploads the APK and the summary of recent changes., there are more task like this available.

It uses the The Google Play Developer API

Solution 3

There is no official Google API for automating working with Google Play. (This is NOT true after July 2014)

You can create a script that encapsulates a web browser and simulates user bevahiour: find HTML fields, enter info there, submitting the page, etc.

We are working on such open-source Python tool: https://github.com/onepf/AppDF/tree/master/tools/uploader

Solution 4

I answered this also on this question, but I figured I'd add the same comment here. Let me know if that's the wrong way to do this (duplicating answers).

I was able to create a gradle plugin that does the publishing to any track you wish for any flavor/variant you wish using the new Google Play Publishing APIs.

See the sources here: https://github.com/bluesliverx/savillians-gradle

I'm working on publishing this to maven central so it can be used in a build script, but for now you can grab the android-publisher subdirectory in the repo, put it in the root of your gradle build, and rename the folder to buildSrc. Use the following line in the build.gradle file for the android project you want to publish:

apply plugin: com.savillians.gradle.androidpublisher.AndroidPublisherPlugin

You can then set your publishing settings using an androidPublisher block in the build.gradle file.

android {
    ...
}
androidPublisher {
    applicationName = "Company-Name-Product-Name/1.0"
    packageName = "<package name>"
    serviceAccountEmail = "<service account email>"
    serviceAccountKeyFile = file('<p12 keyfile - NOT the json file>')
    track = "alpha" // default, don't need to specify
    variantName = "release" // default, don't need to specify
}

Make sure the service account you create has "release manager" permissions, download the p12 key file and put it in the project's directory. Then run this command:

gradle androidPublish

That will send it to Google Play using the credentials you specified. Good luck and let me know if you have questions since this is brand new.

Share:
43,417
Magnus
Author by

Magnus

Updated on July 08, 2022

Comments

  • Magnus
    Magnus almost 2 years

    Is there any API or tool that enables me to automatically upload an APK to Google Play? I want to automatically publish customized apps to my account without any manual steps or graphical interface.

    I searched around but could not find any API for doing this (only android-publisher but it doesn't support publishing, despite its name). Did anyone solve this already, seems like a basic feature?

  • Léo Lam
    Léo Lam almost 10 years
    This was true until late July 2014, when Google added a publishing API. See the answer from sharshi for more info.
  • Léo Lam
    Léo Lam almost 10 years
    Note that the API is only for already published apps (that have at least one APK uploaded).
  • Vitalii
    Vitalii over 9 years
    Authorisation with Google might be a trick. Here's how getting token via command line would look. P.S. The .p12 key mention there will not work until you convert it yo .pem with the command "openssl pkcs12 -in my_google_key.p12 -out my_google_key.pem -nodes -clcert"
  • Vitalii
    Vitalii over 9 years
    UPDATE: Unfortunately as of today the main API command Edits: insert results in error messages of different kind with no solutions yet
  • Richard Le Mesurier
    Richard Le Mesurier over 9 years
    This answer is now wrong.
  • Sankar V
    Sankar V over 9 years
    have a look with this gradle plugin - github.com/Triple-T/gradle-play-publisher
  • Ricardo Pedroni
    Ricardo Pedroni over 9 years
    Does anyone know if the restriction of updating only preexistent apps still apply?
  • ApiFox
    ApiFox about 9 years
    it looks like at this moment there is no way to upload new apks via AndroidPublisher API, only updates accepted?!
  • Nevin Raj Victor
    Nevin Raj Victor about 9 years
    please find stackoverflow.com/questions/29816342/… Does gradle androidPublish generate the signed apk and upload to playstore
  • bksaville
    bksaville about 9 years
    Answered. This plugin will do what you are looking for.
  • Léo Lam
    Léo Lam about 9 years
    @RicardoPedroni Yes, the limitation still applies.
  • Aqib Mumtaz
    Aqib Mumtaz almost 9 years
    Hi, Im new to Gradle, gradle-play-publisher says "Once you have applied this plugin to your android application project you can configure it via the play block", Where I need to add play block?
  • Carlo Espino
    Carlo Espino almost 9 years
    In your build.gradle file
  • Aqib Mumtaz
    Aqib Mumtaz almost 9 years
    Could you please share your build file? Im constantly getting this exception "org.gradle.execution.TaskSelectionException: Task 'publishApkRelease' not found in root project"
  • Aqib Mumtaz
    Aqib Mumtaz almost 9 years
    I have posted my question stackoverflow.com/questions/31449533/…
  • Dokuzov
    Dokuzov almost 8 years
    So it is still for already uploaded APKs?You cannot upload first version of an app through the API?
  • sharshi
    sharshi almost 8 years
    @Dokuzov yes only updates
  • oldergod
    oldergod over 7 years
    not really active project anyhow
  • Carlo Espino
    Carlo Espino almost 7 years
    Why you say is not an active project?
  • Sajith Vijesekara
    Sajith Vijesekara over 6 years
    hi @bksaville is this plugin support for existing apps. Can't we use for newly created apps.
  • Maks
    Maks over 5 years
    I found that instead of "release manager" for the Roles when creating the service account I needed to instead: in the Role dropdown choose "Service Accounts" -> "Service Account User" and "Service Account Token Creator"
  • sathya
    sathya over 5 years
    Any API limit for access this google play store publish API? @sharshi
  • Jay Kukadiya
    Jay Kukadiya almost 3 years
    is this api are free to use?