101

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?

Magnus
  • 3,691
  • 5
  • 27
  • 35
  • 3
    I don't think there is any, but this is an interesting question – Stéphane Feb 02 '13 at 19:39
  • 8
    Times change - let the comment reflect that there IS now such an API - previous comments and answers are now out of date - correct answer is now from sharshi. – Richard Le Mesurier Oct 21 '14 at 09:45
  • Also see: https://stackoverflow.com/a/52374171/1531054 – S.D. Sep 17 '18 at 18:59
  • For those who came here through a web search and just want an answer, offtopic or not: [Fastlane](https://fastlane.tools/) is a tool that automates Play Store and App Store deployments. – Thomas Jul 08 '19 at 10:27
  • There is one: https://github.com/codebysd/java-play-store-uploader – S.D. Jul 27 '19 at 19:40

4 Answers4

65

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/

sharshi
  • 963
  • 11
  • 16
  • 29
    Note that the API is *only* for **already published apps** (that have at least one APK uploaded). – Léo Lam Aug 11 '14 at 08:58
  • Authorisation with Google might be a trick. [Here's how](http://superuser.com/questions/606953/bash-oauth-2-0-jwt-script-for-server-to-google-server-applications) 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 Sep 02 '14 at 10:21
  • UPDATE: Unfortunately as of today the main API command [Edits: insert](https://developers.google.com/android-publisher/api-ref/edits/insert) results in error messages of different kind with [no solutions yet](http://stackoverflow.com/questions/25054919/get-android-subscription-status-failed-with-403) – Vitalii Sep 02 '14 at 13:07
  • 2
    have a look with this gradle plugin - https://github.com/Triple-T/gradle-play-publisher – Sankar V Dec 24 '14 at 07:14
  • 3
    Does anyone know if the restriction of updating only preexistent apps still apply? – Ricardo Pedroni Jan 27 '15 at 19:49
  • it looks like at this moment there is no way to upload new apks via AndroidPublisher API, only updates accepted?! – ApiFox Feb 19 '15 at 07:30
  • @RicardoPedroni Yes, the limitation still applies. – Léo Lam Apr 26 '15 at 19:42
  • So it is still for already uploaded APKs?You cannot upload first version of an app through the API? – Dokuzov Jun 08 '16 at 13:31
  • 1
    @Dokuzov yes only updates – sharshi Jun 08 '16 at 13:32
  • Any API limit for access this google play store publish API? @sharshi – sathya Sep 10 '18 at 11:23
  • is this api are free to use? – Jay Kukadiya Jun 03 '21 at 14:29
23

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

Carlo Espino
  • 1,354
  • 1
  • 15
  • 21
20

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

Dheeraj Bhaskar
  • 18,633
  • 9
  • 63
  • 66
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.

Community
  • 1
  • 1
bksaville
  • 288
  • 2
  • 8
  • please find http://stackoverflow.com/questions/29816342/command-line-upload-of-apk-to-google-playstore Does `gradle androidPublish` generate the signed apk and upload to playstore – Nevin Raj Victor Apr 23 '15 at 09:21
  • Answered. This plugin will do what you are looking for. – bksaville Apr 24 '15 at 15:19
  • hi @bksaville is this plugin support for existing apps. Can't we use for newly created apps. – Sajith Vijesekara Sep 26 '17 at 10:39
  • 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" – Maks Aug 30 '18 at 01:34