title: How to run Android robolectric tests with parallel mode enabled
body: <p>I am finding troubles in running Robolectric tests with parallel mode on over a clean Gradle and Maven cache.</p>
  
  <p>This is build.gradle:</p>
  
  <pre><code>apply plugin: 'com.android.application'
  
  android {
      compileSdkVersion 21
      buildToolsVersion "21.1.2"
  
      defaultConfig {
          applicationId "com.robolectrictest.robotest"
          minSdkVersion 21
          targetSdkVersion 21
          versionCode 1
          versionName "1.0"
      }
  
      testOptions.unitTests.all {
          testLogging {
              events "failed", "skipped"
              showStackTraces = true
              exceptionFormat = "full"
          }
          maxParallelForks = 8
          forkEvery = 20
      }
  }
  
  dependencies {
      compile fileTree(dir: 'libs', include: ['*.jar'])
      testCompile 'junit:junit:4.12'
      testCompile 'org.robolectric:robolectric:3.0'
      androidTestCompile 'junit:junit:4.12'
  }
  </code></pre>
  
  <p>Building on API 23 displays the same issue.
  If I clear the caches (by removing ~/.gradle/caches/ and ~/.m2/repository) and run</p>
  
  <pre><code>./gradlew clean test
  </code></pre>
  
  <p>I encounter the following exception(s):</p>
  
  <pre><code>com.robolectrictest.robotest.ExampleUnitTest1 &gt; addition_isCorrect1_1 FAILED
  Unable to resolve artifact: Unable to get dependency information: Unable to read the metadata file for artifact 'org.robolectric:shadows-core:jar:21': Failed to build model from file '/Users/nicoloparolini/.m2/repository/org/robolectric/shadows-core/3.0/shadows-core-3.0.pom'.
          Error: 'no more data available - expected end tags &lt;/configuration&gt;&lt;/plugin&gt;&lt;/plugins&gt;&lt;/build&gt;&lt;/project&gt; to close start tag &lt;configuration&gt; from line 131 and start tag &lt;plugin&gt; from line 128 and start tag &lt;plugins&gt; from line 119 and start tag &lt;build&gt; from line 105 and start tag &lt;project&gt; from line 2, parser stopped on TEXT seen ...&lt;/generatedSourcesDirectory&gt;\n        &lt;/con... @133:14' for project org.robolectric:shadows-core
  org.robolectric:shadows-core:jar:3.0
  
  from the specified remote repositories:
  sonatype (https://oss.sonatype.org/content/groups/public/),
          central (http://repo1.maven.org/maven2)
  
                  Path to dependency:
                  1) org.apache.maven:super-pom:pom:2.0
  
          Caused by:
          org.apache.maven.artifact.resolver.ArtifactResolutionException: Unable to get dependency information: Unable to read the metadata file for artifact 'org.robolectric:shadows-core:jar:21': Failed to build model from file '/Users/nicoloparolini/.m2/repository/org/robolectric/shadows-core/3.0/shadows-core-3.0.pom'.
          Error: 'no more data available - expected end tags &lt;/configuration&gt;&lt;/plugin&gt;&lt;/plugins&gt;&lt;/build&gt;&lt;/project&gt; to close start tag &lt;configuration&gt; from line 131 and start tag &lt;plugin&gt; from line 128 and start tag &lt;plugins&gt; from line 119 and start tag &lt;build&gt; from line 105 and start tag &lt;project&gt; from line 2, parser stopped on TEXT seen ...&lt;/generatedSourcesDirectory&gt;\n        &lt;/con... @133:14' for project org.robolectric:shadows-core
  org.robolectric:shadows-core:jar:3.0
  
  from the specified remote repositories:
          sonatype (https://oss.sonatype.org/content/groups/public/),
                  central (http://repo1.maven.org/maven2)
  
                          Path to dependency:
                          1) org.apache.maven:super-pom:pom:2.0
  
                  Caused by:
                  org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException: Unable to read the metadata file for artifact 'org.robolectric:shadows-core:jar:21': Failed to build model from file '/Users/nicoloparolini/.m2/repository/org/robolectric/shadows-core/3.0/shadows-core-3.0.pom'.
          Error: 'no more data available - expected end tags &lt;/configuration&gt;&lt;/plugin&gt;&lt;/plugins&gt;&lt;/build&gt;&lt;/project&gt; to close start tag &lt;configuration&gt; from line 131 and start tag &lt;plugin&gt; from line 128 and start tag &lt;plugins&gt; from line 119 and start tag &lt;build&gt; from line 105 and start tag &lt;project&gt; from line 2, parser stopped on TEXT seen ...&lt;/generatedSourcesDirectory&gt;\n        &lt;/con... @133:14' for project org.robolectric:shadows-core
  
  Caused by:
  org.apache.maven.project.ProjectBuildingException: Failed to build model from file '/Users/nicoloparolini/.m2/repository/org/robolectric/shadows-core/3.0/shadows-core-3.0.pom'.
  Error: 'no more data available - expected end tags &lt;/configuration&gt;&lt;/plugin&gt;&lt;/plugins&gt;&lt;/build&gt;&lt;/project&gt; to close start tag &lt;configuration&gt; from line 131 and start tag &lt;plugin&gt; from line 128 and start tag &lt;plugins&gt; from line 119 and start tag &lt;build&gt; from line 105 and start tag &lt;project&gt; from line 2, parser stopped on TEXT seen ...&lt;/generatedSourcesDirectory&gt;\n        &lt;/con... @133:14' for project org.robolectric:shadows-core
  
  Caused by:
  java.io.EOFException: no more data available - expected end tags &lt;/configuration&gt;&lt;/plugin&gt;&lt;/plugins&gt;&lt;/build&gt;&lt;/project&gt; to close start tag &lt;configuration&gt; from line 131 and start tag &lt;plugin&gt; from line 128 and start tag &lt;plugins&gt; from line 119 and start tag &lt;build&gt; from line 105 and start tag &lt;project&gt; from line 2, parser stopped on TEXT seen ...&lt;/generatedSourcesDirectory&gt;\n        &lt;/con... @133:14
  </code></pre>
  
  <p>Now, the file is there, correctly formatted, without any odd special character in it. Looks simply like the process has been interrupted while reading it.</p>
  
  <p>More details: this is the Activity being tested</p>
  
  <pre><code>package com.robolectrictest.robotest;
  
  import android.app.Activity;
  import android.content.Intent;
  import android.os.Bundle;
  import android.view.View;
  
  
  public class MainActivity extends Activity {
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          final View button = findViewById(R.id.login);
          button.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                  startActivity(new Intent(MainActivity.this, MainActivity.class));
              }
          });
      }
  }
  </code></pre>
  
  <p>With its layout:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent"&gt;
  
      &lt;Button
          android:id="@+id/login"
          android:text="Login"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"/&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>And this is the test, repeated 10 times per class with 200 classes to trigger multithreading:</p>
  
  <pre><code>public class ExampleUnitTest1 {@Test
      public void addition_isCorrect1_1() throws Exception {
          MainActivity activity = Robolectric.setupActivity(MainActivity.class);
          activity.findViewById(R.id.login).performClick();
  
          Intent expectedIntent = new Intent(activity, MainActivity.class);
          Assert.assertNotSame(Shadows.shadowOf(activity).getNextStartedActivity(), expectedIntent);
      }
  }
  </code></pre>
  
  <p>I could not find any related bug or issue anywhere. Any ideas?</p>