|
Samples
About the sample code.
Featured Where can I find the samples?This link will take you to the latest stable samples: --> Download samples from the stable branch Important notes:
What are the samples?HelloFlashlightThe HelloFlashlight example represent the simplest setup. It has one module that can be built and deployed with the plugin. MorseFlashThe 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
ScalaThe 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. LibraryProjectsThe 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. ApiDemosApiDemos 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
How to build the samplesYou 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. | |
One of our projects is using this plugin if people are looking for other examples: http://github.com/novoda/oauth_for_android
the morse sample uses an avd named "23", not "16"
Updated
There's an log message that get's spit out by the maven build that still references avd 16.
In order for the native samples to work you need to install "Android NDK" and set environment variable "ANDROID_NDK_HOME"