My favorites | Sign in
Project Home Wiki Issues Source
Search
for
Samples  
About the sample code.
Featured
Updated Nov 26, 2011 by h...@josefson.org

Where can I find the samples?

This link will take you to the latest stable samples:

--> Download samples from the stable branch

Important notes:

  1. Use the above link to get a correct version of the samples! Then you will automatically use a proper released version of android-maven-plugin. If you would use the very latest "master" version of the samples, they will require that you compile the plugin by yourself first. (Full explanation about correct version is on the Source tab.)
  2. Make sure to choose a location with a short path to unzip the package; it has deeply nested structures and you want to stay within the path length limits of your OS. Windows is known to skip some deeply located files when the complete directory path becomes too long.

What are the samples?

HelloFlashlight

The HelloFlashlight example represent the simplest setup. It has one module that can be built and deployed with the plugin.

MorseFlash

The MorseFlash is the most comprehensive example available. It has a plain java library module, the application module and a instrumentation test module. Among other things it features

  • different profiles for development vs release build including setup for signing, zipaligning and proguard usage
  • resource filtering setup
  • automatic emulator start
  • unit tests in library and apk module
  • instrumentation tests running emulator
  • profiles for auotmatically correct behaviour under different build operating systems

Scala

The Scala example show you how to build an Android application written with the Scala language and how to use Proguard to reduce the size of the resulting package.

LibraryProjects

The LibraryProjects example shows how to set up Android Library Projects. An app project called libraryprojects-mainapp has dependencies to two libraries of type apklib. There are also instrumentation tests to verify that all different kind of resources from the libraries are reachable from the main app.

More documentation on Android Library Projects: ApkLib.

ApiDemos

ApiDemos is a sample application that comes with the Android SDK converted to use a Android Maven Plugin based build.

The samples are meant to show you how to create a pom.xml and structure your project to work with Android Maven Plugin.

For example, the apidemos sample has this structure:

|
\-- apidemos-android-10
  \
  +--- application
  |
  \--- instrumentationtests
  • The directory name apidemos-android-10 means it contains ApiDemos from Android SDK at API level 10.
  • It is split up into two Maven projects:
    • application, which contains a pom.xml and source code for the application apk.
    • instrumentationtests, which contains a pom.xml and source code for instrumentation tests of the app.

How to build the samples

You can build all samples in one go by running

mvn clean install 

in the samples root folder. As a prerequisite you have to have an emulator of API level 4 (platform 1.6) or higher running or equivalent device connected. Otherwise the build will try to start an emulator named "23" for you. An Android Virtual Device of that name has to exist for the build to succeed.

You can also run each example separately with the same command. Sample specific documentation can be found in the README.txt file in each project folder.

For example if you have set up your development environment according to GettingStarted, you can build for example the ApiDemos like this:

 cd apidemos-android-10
 mvn install

When you build from that directory, you will build both the application project and instrumentation test project. They both generate an apk each.

As part of the instrumentationtests project, Android Maven Plugin will deploy both apk files to the connected device or emulator and run the instrumentation tests inside the device.

Comment by project member novo...@gmail.com, Oct 27, 2009

One of our projects is using this plugin if people are looking for other examples: http://github.com/novoda/oauth_for_android

Comment by thier...@gmail.com, Mar 18, 2011

the morse sample uses an avd named "23", not "16"

Comment by project member mosa...@gmail.com, Mar 18, 2011

Updated

Comment by james.ta...@jrtechnical.com, Feb 14, 2012

There's an log message that get's spit out by the maven build that still references avd 16.

Comment by borja.r...@gmail.com, Feb 14, 2012

In order for the native samples to work you need to install "Android NDK" and set environment variable "ANDROID_NDK_HOME"


Sign in to add a comment
Powered by Google Project Hosting