Hardcode shadows-multidex ShadowProvider file.

These files are generated by the Robolectric annotation processor
at compile time. The generated files are difficult to use given
our Chromium build system (GN). Hardcoding the file for


Review URL: https://codereview.appspot.com/308880043 .
1 file changed
tree: 8c21bc04d47fc5bb05b81d95eedb33b051717961
  1. .gitignore
  2. .travis.yml
  4. LICENSE.txt
  5. README.md
  6. images/
  7. pom.xml
  8. robolectric-annotations/
  9. robolectric-processor/
  10. robolectric-resources/
  11. robolectric-shadows/
  12. robolectric-utils/
  13. robolectric/
  14. scripts/

Build Status

Robolectric is a testing framework that de-fangs the Android SDK so you can test-drive the development of your Android app.


Here's an example of a simple test written using Robolectric:

public class MyActivityTest {

  public void clickingButton_shouldChangeResultsViewText() throws Exception {
    Activity activity = Robolectric.setupActivity(MyActivity.class);

    Button pressMeButton = (Button) activity.findViewById(R.id.press_me_button);
    TextView results = (TextView) activity.findViewById(R.id.results_text_view);

    String resultsText = results.getText().toString();
    assertThat(resultsText, equalTo("Testing Android Rocks!"));

For more information about how to install and use Robolectric on your project, extend its functionality, and join the community of contributors, please visit http://robolectric.org.


Starting a New Project

If you'd like to start a new project with Robolectric you can use deckard (for either maven or gradle). These project will guide you through setting up both Android and Robolectric on your machine.


testCompile "org.robolectric:robolectric:2.4"



Robolectric requires the Google APIs for Android (specifically, the maps JAR) and Android support-v4 library. To download this onto your development machine use the Android SDK tools and then run the following to install them to your local Maven repository (you will need to have the ‘Android Support Repository’ installed):

mvn install:install-file -DgroupId=com.google.android.maps \
  -DartifactId=maps \
  -Dversion=18_r3 \
  -Dpackaging=jar \

mvn install:install-file -DgroupId=com.android.support \
  -DartifactId=support-v4 \
  -Dversion=19.0.1 \
  -Dpackaging=jar \

You will need to either replace or have ANDROID_HOME set to your local Android SDK for Maven to be able to install the jar.

Building And Contributing

Robolectric is built using Maven. Both Eclipse (with the M2Eclipse plug-in) and IntelliJ can import the pom.xml file and will automatically generate their project files from it. You will need to have portions of the Android SDK available in your local Maven repo in order to build Robolectric.

Mavenize all required dependencies by running:


Because Robolectric's shadows are compiled against the Android APIs that they target, you must build the shadows for all API levels before being able to run any of the tests. You can build all of Robolectric by running:


After doing this once, you can build and test against the specific API level you care about:

mvn install -P android-18 (for example)

Using Snapshots

If you would like to live on the bleeding edge, you can try running against a snapshot build. Keep in mind that snapshots represent the most recent changes on master and may contain bugs.


repositories {
    maven { url "https://oss.sonatype.org/content/repositories/snapshots" }

dependencies {
    testCompile "org.robolectric:robolectric:3.0-SNAPSHOT"