Posted on by | Posted in Developer Blog, Mobile Blog, Tutorial | Tagged , , , ,

In my previous post, I showed you the basic setup for android with maven using the android-maven-plugin. Now I'll show you how to configure it to make releases with maven, and how to configure the plugins to save you some work.

Configuring the keystore data

If you have used the release archetype like in the previous post, most of the work is already done. The necessary plugins are configured and only need some additional data, like the data for your release keystore.

Looking into the poms, you'll find the property keys, you have to provide:


Simply configure them into your maven settings.xml in the release profile (which is also configured in the parent pom):
(If you don't have a release key yet, check this out


For our case, we removed everything related to proguard from the configs, beacuase we don't use it for this project. Instead of removing everything, you could also just disable it with the android-maven-plugin configuration


Adding scm connection and distribution management

Like you would normally, using maven releases, you have to add an scm connection to your parent pom, e.g.:


If you have a server to deploy your maven artifacts to, now is the time to add it to your config (if you only build and deploy them from your local machine, you don't need this):


Configure the Android Manifest from Maven

To save us some nasty work, we also want to configure the Android manifest with our maven profiles (e.g. setting Debug to false for release, automatically update the version on releases, etc.)

For this, we'll need to filter the manifest in maven:
add following plugins to the parent pom:


... and the config for them in the app module (and IT module) pom:


Don't forget to update the Android manifest path in the android-maven-plugin to the filtered manifest location!


In the Android Manifest files of the modules, you can now insert the maven property placeholders for the versionCode and versionName

If you now build your project (clean install), the generated Android manifest should include the versionCode "100" and the version "1.0-Snapshot" (If you didn't change the version in the pom, yet).

Other than that, you have plenty of configuration possibilities of your AndroidManifest within the android-maven-plugin config, and with this setup you can easily alter the values for the different build profiles.

Building the release

To build the release, use

mvn release:prepare -Prelease

release:perform is not necessary here!

After the release is done, run

mvn release:clean

to clean up.

Note: you might want to let your scm ignore some files (e.g. and the target folders) so that you don't have to further clean up your directories after you run the release.

That's it, now you are able to build your android app releases with maven!

Here are the sources to check against: my-android-project sources

My next blog will be about Android & Continuous integration with Jenkins, so check our blog from time to time ­čÖé

2 Responses to Building Android projects with maven – part 2: Releases with maven

  1. HI Tobias,
    Nice explanation. I released my project on maven central. The group id is com.embeddedunveiled and artifact is scm. Please guide me which is the link that I should give to other developers so that they can integrate my artifact in their project.

  2. Pingback: Building Android projects with Maven – Part 1: Setup | synyx - Blog

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht ver├Âffentlicht. Erforderliche Felder sind mit * markiert.