Logo Icon Logo
A Crowd-sourced Cookbook on Writing Great Android® Apps
GitHub logo Twitter logo OReilly Book Cover Art
Creating a "Hello, World" App with Apache MavenBack to Android Cookbook Home | Up to Chapter: Getting Started

Author: Ian Darwin ('idarwin')
In Published Edition? Yes
FormatLanguage: WikiFormat

Creating a "Hello, World" App with Apache Maven


You want to build an Android app using Maven to handle the administrivia.


Use maven to create the project, and to build it, as shown below.


There are several approaches to using Apache Maven to build Android. Here's one I've tested, based upon the akquinet maven-android-archetypes.

$ mvn archetype:generate \

 -DarchetypeArtifactId=android-quickstart \
 -DarchetypeGroupId=de.akquinet.android.archetypes \
 -DarchetypeVersion=1.0.8 \
 -DgroupId=com.androidcookbook \
 -DartifactId=android-demo \
 -Dplatform=7 \

$ mvn clean install

Before the next step, you should plug in a device, or start an emulator

$ mvn android:deploy # (not mvn deploy!) this will package and install, but not run, the app

$ mvn android:run # This will run the app

Most of the -D arguments are obvious. "platform" is the API level (7 = Eclair, 10 = Gingerbread, etc.). There is more to this; you can specify a number of other parameters and variations, including test projects.

Maven has support for other operations, including signing the APK for release.

See Also

http://stand.spree.de/wiki_details_maven_archetypes - Getting Started with archetypes, in more detail.

https://github.com/akquinet/android-archetypes - the source code for the artifacts

It is possible to "eclipsify" the project using Maven; this step is left as an exercise for the reader (something similar has been done to create the Eclipse files in the downloadable version of this project).


The source code for this project is in the Android Cookbook repository, http://github.com/IanDarwin/Android-Cookbook-Examples/tree/master/HelloMaven