Skip to content

Signing configuration

Evgeniy Tsvigun edited this page Jun 27, 2015 · 3 revisions

Manual signing

After you generate a private key set up your keystore, check if manual signing and zipaligning works for you: http://developer.android.com/tools/publishing/app-signing.html#signing-manually

Auto signing

If you want android-sdk-plugin to automatically sign release packages, add the following lines to local.properties (or any file.properties of your choice that you will not check in to source control):

key.alias: KEY-ALIAS
key.alias.password: PASSWORD (optional, defaults to key.store.password)
key.store: /path/to/your/.keystore
key.store.password: KEYSTORE-PASSWORD
key.store.type: pkcs12 (optional, defaults to jks)

If you have a multi-module project, make sure the .properties file is in the root of android module.

Gitignore

Putting the signing configuration in your version control ignore file should be a nice move. For example, put the name of your signing config to .gitignore together with the rest of ignored files:

signing.properties

android/bin/
android/gen/
android/libs/
android/target/
...

Expected output example

    $ sbt android:package-release
    ...
    [info] Signed: android-release-unaligned.apk
    [info] zipaligned: android-release.apk
    [success] Total time: 7 s, completed 25-Jun-2015 20:02:47

Prompting for passwords

On the other hand, if you'd rather prompt for keystore and key passwords when running package-release, use an alternative signing config

To prompt for passwords, add something like this to your build:

    apkSigningConfig in Android := Option(
      PromptStorepassSigningConfig(
        //Ask for keystore password only. 
        //To ask for both keystore and key paswords, 
        //use PromptPasswordsSigningConfig instead
        keystore = new File(
          Path.userHome.absolutePath + 
            "/.android/release.keystore"
        ),
        alias = "my-alias")
    )