Google Play
Upload AAB and APK directly via the Google Play Developer API: create a service account, grant it access in the Play Console, pick a track, test it.
The Build Station uploads AAB and APK files directly via the Google Play Developer API. It doesn’t need fastlane or Ruby for this, just a service account with upload rights for the app. You set it up once per project; after that it’s a single button.
Requirements
- A Google Play developer account with the app.
- The applicationId is entered in the project (project editor). Without it, the Station doesn’t know which app is meant.
- You’ve uploaded the very first version of the app once by hand in the Play Console. Before that, the API doesn’t know the package name.
Step by step
Open Projekt bearbeiten › Upload › Store-Upload einrichten (Edit project › Upload › set up store upload) and then the Google Play tab. It lists the same steps with direct links.
- Create a service account. Create a service account in the Google Cloud Console. No role is needed. Under Keys › Add key › JSON, generate a key file and download it.
- Enable the API. In the same Cloud project, enable the Google Play Android Developer API.
- Grant access in the Play Console. In the Play Console, under Users and permissions, invite the service account’s email address and allow Release management for the app.
- Store the key. In the setup, switch on Direkt über die Google Play API hochladen (upload directly via the Google Play API), choose the JSON file and set the Track.
- Test the connection. The test creates an edit in the Play Console and discards it right away. It doesn’t change anything.
Übernehmen (apply) saves the settings. The content of the JSON file is then stored in this Mac’s macOS keychain. The Station no longer needs the downloaded file.
The service account JSON is full-fledged access to the Play account. Never put it in the repository.
Track and draft
| Track | What for |
|---|---|
internal |
internal testing, the default |
alpha |
closed testing |
beta |
open testing |
production |
published to all users |
If you choose production, the Station explicitly points this out. For test distribution, internal is the one you want.
If the app has never been published in the Play Console, Google only accepts releases as a draft. In that case, set Nur als Entwurf (draft only) and then release it in the Play Console.
Uploading
After a successful Android build, the Hochladen (Upload) section shows the Jetzt hochladen · Google Play (internal) (upload now) button, with the selected track in parentheses. The confirmation shows the API calls and a field for release notes. They go to the track as “What’s new in this version”.
The upload runs in four steps:
- create an edit
- upload the AAB or APK
- assign it to the track
- commit
If a step fails, the Station discards the edit. Nothing half-done is left in the Play Console.
The upload runs through the queue and is listed in the history with its log. Afterwards, the Station ticks off “Version/Build-Nummer geprüft” (version/build number checked) and “AAB in Play Console hochgeladen” (AAB uploaded to Play Console) in the checklist and, if you like, sets a Git tag. See Artifacts and upload.
What’s in the store
With the upload set up, the Station asks Google Play which build number was uploaded last. That’s shown in the Build tab below the version and in the Übersicht (Overview), with the suffix “laut Store” (according to the store). It also derives the next build number from this, so no upload fails on a number that’s already taken.
Common errors
| Message | Cause |
|---|---|
| „Google Play verweigert den Zugriff” (Google Play denies access) | Service account not invited in the Play Console, no rights for this app, or the Android Developer API isn’t enabled in the Cloud project. |
| „Google Play kennt … nicht” (Google Play doesn’t know …) | Wrong package name, or the first version was never uploaded by hand. |
| „Diese Build-Nummer (versionCode) ist schon hochgeladen” (this build number has already been uploaded) | Increase the build number and rebuild. |
| „Die App ist in der Play Console noch ein Entwurf” (the app is still a draft in the Play Console) | Set Nur als Entwurf. |
The Station recognizes the first three itself: a strip with the cause and a button back to the setup appears above the log.
Removing credentials
Aus Schlüsselbund entfernen (remove from keychain) in the setup deletes this project’s service account from the Mac. Alternatively, you’ll find the entry in Keychain Access under the service de.inwendo.buildstation.store.
Alternative: fastlane
If you already maintain a fastlane setup, you can use fastlane supply or your own lane instead of the API. See fastlane.