Manually Sign Android APKS#

Currently, two products may need manually signing:

  • Firefox Rocket

  • Firefox Focus for Android. :warning: This product has two APKs: one is Focus, the other for the German-speaking population: Klar.


Google Play refuses non-optimized APKs. The signature changes the structure of the APK archive, which breaks the Zip optimization.

  1. Install the latest Android SDK to get the build tools.

    • MacOSX: brew cask install android-sdk (requires brew tap caskroom/cask)

      • then run sdkmanager --list and install build-tools, e.g. sdkmanager 'build-tools;27.0.3'. It’ll show up in e.g. /usr/local/share/android-sdk/build-tools/27.0.3/zipalign

    • Ubuntu: apt install android-sdk

    • Other: Install Android Studio

First Steps#

  1. ssh

  2. Change to the cltsign user:

    sudo su - cltsign

To sign an APK#

You will need to repeat this for each APK, feel free to optimize by downloading all at once, just be careful of filenames when copy/pasting commands.

  1. Download unsigned APK(s).

    • Right-click the attachment in bugzilla and click ‘Copy Link Location’

    • wget -O unsigned.apk <pasted url>

  2. Set environment variables:

    • For Focus/Klar:

    • For Rocket:

  3. Look up the right keystore password in the releng private repo

    • Focus/Klar is under the name signing-server-focus

    • Rocket is under the name signing-server-rocket

  4. jarsigner -keystore "$keystore" unsigned.apk "$alias" You’ll be asked for the password in the previous step. The Klar APK uses the same certificate alias/password as focus. You’ll also get an expected warning:

    No -tsa or -tsacert is provided and this jar is not timestamped. Without a timestamp, users may not be able to validate this jar after the signer certificate's expiration date (2044-10-25) or after any future revocation date.
  5. mv unsigned.apk signed.apk

  6. Verify signatures: jarsigner -verify -verbose -keystore "$keystore" signed.apk "$alias"

  7. If your product has several APKs, repeat the previous steps. You may want to give the files more useful names, such as app-rocket-webkit-release-signed.apk

After all the signing#

  1. Fetch signed APK(s) on your local machine. You will need to copy the files to your own user account in order to scp them, as you can’t directly reach the cltsign user.

  2. Optimize the APKs for Google Play, and verify. For each APK:

    zipalign -v 4 signed.apk signed-aligned.apk
    zipalign -c -v 4 signed-aligned.apk
  3. Attach the signed and aligned APKs to the bug using the ‘attach file’ feature in bugzilla.


Can’t sign APKs#

Sometimes, APKs aren’t correctly formatted. For instance, CI may have already signed an APK with a dev key. In this case, you may see:

$ jarsigner -verbose -keystore "$keystore" unsigned.apk "$alias"
Enter Passphrase for keystore:
jarsigner: unable to sign jar: invalid entry compressed size (expected 34549 but got 35093 bytes)

The fix is just to strip the signature from the package:

$ zip -d unsigned.apk META-INF/\*
deleting: META-INF/CERT.SF

Then you can resume signing.


We already have a github repo with taskcluster release builds. It’s not trivial, but it’s possible we could add CoT and auto-sign these release builds.