Deckard is the simplest possible Java Android application project that uses Robolectric/Espresso for testing and Gradle to build. It has one Activity, a single Robolectric test of that Activity, and an Espresso test of that Activity.
Deckard imports easily into the latest editions of Android Studio with minimal setup.
Note: A Kotlin variant of this template is also available here.
Note: These instructions assume you have a Java 1.8 JDK installed.
To start a new Android project:
-
Install Android Studio 2.3.
-
Download Deckard as a zip here and then extract it on your dev machine.
-
Import the template into Android Studio by clicking "Import project" and selecting the project directory.
-
Change the names of things from 'Deckard' to whatever is appropriate for your project. Package name, classes, build.gradle, and the AndroidManifest are good places to start.
-
Build an app. Win.
-
In the project directory you should be able to run the Robolectric tests:
./gradlew test
-
You can also run the Espresso tests:
./gradlew connectedAndroidTest
Note: Make sure to start an Emulator or connect a device first so the test has something to connect to.
-
Finally you can build a debug
.apk
of the project for installation on phones:./gradlew assemble
This will output the file to
build/outputs/apk/*-debug.apk