Agent commands

The command Agents use to manage the Team's Android signing keys: list, check, create, import, restore, and export them.

android-key manages the Team’s Android app keys. AirBuild holds one active key per Android app, and every build of that app is signed with it: the emulator .apk, the APK people download, and releases made with runbuild --sign. A key that is replaced is archived, never deleted, and can be made active again.

Where it runs

The same command is available to Agents on a cloud Team and on a Mac Team. Sign-in comes from the Agent’s environment, so there is nothing to set up. The command needs curl and jq, which the environment provides. See Choose where your Agents run.

How an app gets its key

  • Automatically. The app’s first build, when it has no active key, makes one. Its origin is auto.
  • Through the chat card. An Agent can send an android_upload_key card; the person uploads an existing keystore or creates a new key on it.
  • With this command. import stores a keystore file the person provides; create makes a new key.

An app already on Google Play must keep its upload key.

Synopsis

android-key list [--json]
android-key status PACKAGE [--json]
android-key create --package PACKAGE [--json]
android-key import FILE --package PACKAGE [--password-entry NAME [--password-field LABEL]] [--json]
android-key activate PACKAGE KEY_ID [--json]
android-key certificate PACKAGE [--key KEY_ID] [--output FILE] [--json]
android-key export PACKAGE [--key KEY_ID] [--output FILE] [--json]
android-key --help

PACKAGE is the app’s applicationId, such as com.example.app: at least two dot-separated parts, each starting with a letter, up to 150 characters. status, create, certificate and export take it either as their first argument or as --package PACKAGE.

Commands

Command What it does
list Every key the Team holds, active and archived, for every app.
status PACKAGE The app’s active key, then its archived keys.
create Makes a new key for the app and makes it active. A key the app already had is archived.
import FILE Sends a keystore to AirBuild, which checks it and stores its key as the app’s active key. A key the app already had is archived.
activate PACKAGE KEY_ID Makes an archived key active again; the active one is archived. status shows the ids.
certificate PACKAGE Prints the key’s certificate as PEM. The certificate only, no private key.
export PACKAGE Writes the key as a keystore file and a .properties file beside it.

The active key signs every later build of the app, the emulator .apk included.

Options

Option Commands Value Default Meaning
--package status, create, import, certificate, export An applicationId — The app. Required by import, whose first argument is the keystore file.
--key certificate, export A key id (UUID) The active key Which key.
--output certificate A file Print to stdout Writes the PEM to this file.
--output export A file ./PACKAGE.keystore Where to write the keystore. Neither it nor FILE.properties may exist yet.
--password-entry import A Passwords entry name Read from stdin Reads the keystore password from the Team’s Passwords.
--password-field import A field label Password The field of --password-entry that holds the password.
--json all — Off Prints the JSON answer instead of text. On an error it also prints the JSON error on stderr.

Importing a keystore

  • FILE is the person’s keystore, at most 64 KiB.

  • It must be PKCS#12: what Android Studio and keytool make today, often still named .jks. The old JKS format is not supported. Ask the person to convert it, or to export it again from Android Studio:

    Terminal window
    keytool -importkeystore -srckeystore FILE -destkeystore upload.p12 -deststoretype pkcs12
  • A PKCS#12 keystore has one password. It is read from the first line of stdin, or from a Team Passwords entry with --password-entry. Passwords never go on the command line: options such as --password or --store-password are refused. See password-book for the Team’s Passwords.

  • AirBuild checks the password and that the key matches its certificate.

  • After a successful import, the command reminds you to delete the keystore file and any other copy you made.

Exporting a key

export writes two files, both readable only by their owner (mode 600):

PACKAGE.keystore             a PKCS#12 keystore, key alias "upload"
PACKAGE.keystore.properties  storeFile, storePassword, keyAlias, keyPassword

The properties file looks like this, with the real password:

storeFile=com.example.app.keystore
storePassword=...
keyAlias=upload
keyPassword=...

Each export has a fresh password. Nothing secret is printed.

Output

list:

PACKAGE          STATUS    ORIGIN    SHA-256                 ID
com.example.app  active    imported  3FA1…                   <key-id>

With no keys it prints The Team holds no Android upload keys yet.

status, and each key in the output of create, import and activate:

Active key for com.example.app:
  id           <key-id>
  status       active
  origin       created
  sha256       <certificate fingerprint>
  valid until  2051-11-19
  created      2026-11-19 by <id>

status lists each archived key the same way, each under its own Archived: line. An app without an active key prints com.example.app has no active upload key. The first signed build creates one; if the app is already on Google Play, import its keystore first.

sha256 is the certificate’s SHA-256 fingerprint, the one Google Play Console shows. origin is auto, created or imported; status is active or archived.

create, import and activate print This key now signs com.example.app: and the key, then, when another key was replaced, Archived (restore with android-key activate com.example.app <key-id>): and that key. When nothing changed they print Nothing changed: this key already signs com.example.app.

export prints the paths, key id and fingerprint:

Wrote the active key for com.example.app (PKCS#12, alias upload, mode 600):
  keystore    ./com.example.app.keystore
  properties  ./com.example.app.keystore.properties  (storePassword, keyPassword, keyAlias; not shown here)
  id          <key-id>
  sha256      <certificate fingerprint>
Send both files only to the person who asked for them, then delete your copies.

Exit codes

Code Meaning
0 Success.
1 AirBuild refused the request, or a file could not be read or written.
2 A usage error: an unknown command or option, a missing argument, or a value in the wrong form. Followed by Run 'android-key --help' for usage.

When AirBuild refuses a request, the command prints Error: <reason> and, on the next line, Code: <code>. The reason says what to do.

Errors

The command’s own messages start with Error:; AirBuild’s refusals add a Code: line.

Message or code What to do
'…' is not an Android applicationId (such as com.example.app). Pass the app’s applicationId.
'…' is not a key id (android-key status shows them). Copy the id from android-key status.
passwords never go on the command line. Pipe it on stdin or use --password-entry NAME. Pipe the password, or save it in the Team’s Passwords and use --password-entry.
pipe the keystore password on stdin, or pass --password-entry NAME. The same.
a PKCS#12 keystore has one password; name its field with --password-field. Use --password-field instead of a separate key-password option.
could not read "Password" from the Passwords entry "…". Check the entry and field names with password-book get NAME.
cannot read the keystore '…'. / the keystore '…' is empty. Check the file path.
the keystore is larger than 64 KiB; it is not an upload keystore. Ask the person for the right file.
android_keystore_jks_unsupported The file is in the old JKS format. Have it converted with the keytool command above, or exported again from Android Studio.
android_keystore_password_wrong The password does not open the keystore. Ask the person for the right one.
android_keystore_multiple_keys The keystore holds more than one private key. Ask for a keystore with only the upload key.
android_keystore_key_mismatch No certificate in the keystore matches its key.
android_keystore_invalid The file could not be read as a keystore.
'…' already exists; move it away or pass another --output. export never overwrites; choose another path.
--output '…' is a directory; name the keystore file. Pass a file name.

Examples

See the app’s active key and its fingerprint:

Terminal window
android-key status com.example.app

Import a keystore the person attached, with its password saved in the Team’s Passwords:

Terminal window
android-key import upload.jks --package com.example.app \
  --password-entry "Android keystore com.example.app"

Save the upload certificate to a file:

Terminal window
android-key certificate com.example.app --output upload_certificate.pem

Bring back the key that was replaced:

Terminal window
android-key activate com.example.app 0b7c2d3e-0000-4000-8000-000000000000