How to sign an Android application using Maven

One function that have not yet made it in to the Maven Android plugin is application signing (it is raised as an issue). It is however possible to achieve this using the maven jarsigner plugin with some simple configuration of the pom.

It is assumed that you are using the project structure presented in previous blog posts on maven android automation (1, 2, 3)

In your parent pom you add the following profile:

Replace the following values in the above snippet:

  1. keystore the path to your key store.
  2. keypass the password for the key that will be used.
  3. storepass the password for the key store.
  4. alias the alias for the key to use.

To sign the apks, including the tests, use the following command:

The configuration will bind the jarsigner plugin to the package phase of the execution when enabled with the -Psign switch in the build. Rather then storing the passwords in clear text in your pom you can pass them to maven as arguments when you execute the command. Go to the jarsigner plugins documentation page for information on how it works and how it can be configured.