Deckard is the simplest possible Android project that uses Robolectric for testing and Maven to build. It has one Activity (with an empty layout), and a Robolectric test that creates that Activity.
Deckard also imports seamlessly into IntelliJ, due to IntelliJ's support for Maven. Just import the pom.xml.
Eclipse is also supported. Install the m2e-android plugin for Eclipse, and import the project as a Maven project. After importing into Eclipse, you have to mark the consume-aar goal as ignored, since aar consumption is not yet supported by m2e-android. To do this, simply apply the Quick fix on the "Plugin execution not covered by lifecycle configuration" error.
Note: These instructions assume you have a Java 1.6 JDK installed.
To start a new Android project:
-
Install the Android SDK. On Mac OS X with Homebrew just run:
brew install android-sdk
-
Set your
ANDROID_HOME
environment variable to/usr/local/opt/android-sdk
. -
Install Maven if you haven't already (run
mvn
to check). On OS X (as before) this is easiest with Homebrew:brew install maven
-
Download Deckard from GitHub:
wget https://github.com/robolectric/deckard-maven/archive/master.zip unzip master.zip mv deckard-maven-master my-new-project
-
Run the setup script to install dependencies into Maven:
my-new-project/setup.sh
-
In the project directory you should be able to run the tests:
cd my-new-project mvn clean test
-
Optionally, import the project into IntelliJ (or Eclipse) by selecting 'Import Project' in IntelliJ and selecting the project's
pom.xml
. When prompted to pick an SDK you just need to select the Android SDK home and your JDK. -
Change the names of things from 'Deckard' to whatever is appropriate for your project. Package name, classes, and the AndroidManifest are good places to start.
-
Build an app. Win.