Android with Maven

Ever since making the switch from Ant to Maven 2 back in 2005, I’ve never looked back. So one of the first things I wanted to know was if I could use maven to build my Android apps. And of course, you can.

Here’s an example pom.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns=""
    <description>Learning Android!</description>
                        <!-- platform or api level (api level 4 = platform 1.6) -->

There are certainly plenty of maven detractors, but the reasons why I prefer maven to ant (or any other tool that’s available at the moment):

  • XML is a reasonably good format for configuration. It is a terrible format for programming. With ant, you are essentially programming a build with XML. Maven configures builds with XML.
  • Programming a build leads to developers doing…whatever they want. But builds should not be particularly complex things, and with a few conventions can be very standardized. This is what maven does.
  • A maven expert is immediately a build expert for any product that builds with maven. Not so much with Ant (or any other build tool that gives the build developer freedom to program the build however they want).
  • Maven’s dependency management system is the right way to handle dependencies. There’s no checking jar files into source control, just some configuration specifying what your dependencies are.


  1. Android appears to moving towards using Gradle as it’s official build system, although it may not be ready for primetime yet. Gradle certainly has a lot of momentum in the industry.
  2. Maven creates .apklib files for android dependencies, which allows android dependencies to have xml resource files in them. This is great, except that the apklib concept is specific to maven. IntelliJ (and presumably the extremely beta Android Studio) will support these types of dependencies, but Eclipse knows nothing of them.