How to integrate Android Development Tools and Maven

April 2nd, 2010 by

With the Maven Android Plugin it is possible to build and deploy/undeploy your android app and start/stop the emulator – if you’re used to maven you won’t be going without it ;)

If you’re interested in signing your apk using maven – take a look at this article.


Project Setup

  • Create an android project using the android tool
  • We need some dependencies – so create a pom.xml in the project’s root directory – I took this from the plugin samples and modified it:
    <?xml version="1.0" encoding="UTF-8"?>
     Copyright (C) 2009 Jayway AB
     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at
     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
    <project xmlns="" xmlns:xsi="" xsi:schemaLocation="">
     <name> - Sample Android App using the Maven Android Plugin</name>
  • Manually change the directory structure – hopeful there will be some archetype stuff in the future
    mv src java && mkdir -p src/main && mv java src/main/
  • Another way is to tell Maven where the source directory is:
  • We won’t need some directories – delete them if they exist
    rm -r bin build.xml libs
  • Build and install the app
    mvn install
    mvn maven-android-plugin:deploy

Maven Dependencies for Android



How to shorten the ultra-mega-thousand-miles-long command line

  • Avoid bleeding fingers by adding the pluginGroup to your Maven config ~/.m2/settings.xml:
    <settings xmlns=""
  • So instead of this command:
    mvn -Dandroid.file=demo.apk
  • We are able to type this stuff:
    mvn android:deploy -Dandroid.file=demo.apk
  • More Information here: Maven Android Plugin – Tips & Tricks

Useful Plugin Goals

  • android:apk – creates a new apk file
  • android:deploy – deploys the apk to a connected device
  • android:emulator-start - starts the emulator with a specified android virtual device
  • android:emulator-stop – stops the emulator
  • android:pull/android:push – copies files/dirs from/to device
  • android:undeploy – undeploys the apk from a connected device
  • A list of all supported goals can be found here


Article Updates

  • 2015-03-03: Table of contents added.

    Tags: , , , , ,

    Leave a Reply

    Please leave these two fields as-is:

    Protected by Invisible Defender. Showed 403 to 113,812 bad guys.