Support free tutorials

Quick links

Building Android Apps with Apache Maven - Tutorial

Lars Vogel

Version 0.3


Android Maven

This tutorial describes how to build Android applications with Apache Maven and the "android-maven-plugin".

Table of Contents

1. Gradle for building Android applications
2. Building Android applications with Maven
3. Tutorial: Building Android Applications with Maven
4. Move information

1. Gradle for building Android applications

The build process of Android projects is handled by the Gradle build system. If you create a new project in Android studio, the Gradle build scripts are automatically created. Android studio wraps the Gradle runtime, hence no additional installation is required.

The Gradle build system is designed to support complex scenarios in creating Android applications:

  • Multi-distribution: the same application must be customized for several clients or companies

  • Multi-apk: supporting the creation of multiple apk for different device types while reusing parts of the code

You can also use a wrapper script created by Gradle which allows you to run a Gradle build without any additional installation from the command line.

2. Building Android applications with Maven

The android-maven-plugin plug-in allows to build Android applications via Maven.

The webpage of this maven plug-in is located under: Android-Maven Plug-in.

The Eclipse support of this plug-in is provided by the m2e project.

You only have to install Maven, write a correct pom.xml file and issue the commands to Maven to build, install and run your application.

The following will build your Android application via Maven.

mvn3 clean install 

This will create the application and places the .apk file in the target folder.

If you want to install the application via Maven on your Android device, you can use the following command.

mvn3 android:deploy 

If more then one device is available you can specify the relevant device in your pom.xml. Maven can also start and stop an Android virtual device automatically for you.

You can also start the application via Maven.

mvn3 android:run 

3. Tutorial: Building Android Applications with Maven

Create a new Android project called "". The actual content of the repository is not important as we are only using this project to create a working build for Maven.

Create the following "pom.xml" file in your directory. Make sure that artifactId is set to your project name.

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="" 
 <name>Maven Example</name>

      <!-- platform or api level (api level 4 = platform 1.6) -->

Switch to the command line and enter the following command:

mvn3 android:deploy 

4. Move information

For more information see the complete Maven Android Guide from Sonatype: Android Application Development with Maven.

Another quick starting guide is available on the android-maven-plugin project side: Getting Started with Android and Maven