title: Robolectric + JaCoCo | Issue while running unit test and not generating code coverage
body: <p>I have added <strong>Robolectric</strong> to get support of Shadow APIs for writing unit tests. Able to get coverage percentage through default Intellij code coverage tool in Android Studio.</p>
  <p>Now trying to add JaCoCo to get enhanced coverage report.</p>
  <p>I'm using file <code>build.gradle(app)</code> for putting <br/>
  plugin as <code>apply from: &quot;$rootDir/jacoco.gradle&quot;</code> and <br/>dependency as <code>testImplementation 'org.robolectric:robolectric:4.3.1'</code></p>
  <br/>
  <p><strong>jacoco.gradle</strong></p>
  <pre><code>apply plugin: 'jacoco'
  
  /*jacoco {
      // https://bintray.com/bintray/jcenter/org.jacoco:org.jacoco.core
      toolVersion = &quot;0.7.1.201405082137&quot;
  }*/
  
  android {
      testOptions {
  
          unitTests {
              includeAndroidResources = true
          }
  
          unitTests.all {
              systemProperty 'user.home', System.getenv('HOME')
              jacoco {
                  includeNoLocationClasses = true
              }
          }
  
          unitTests {
              returnDefaultValues = true
          }
      }
  }
  
  project.afterEvaluate {
  
      android.applicationVariants.all { variant -&gt;
          def name = variant.name
          def testTaskName = &quot;test${name.capitalize()}UnitTest&quot;
  
          tasks.create(name: &quot;${testTaskName}Coverage&quot;, type: JacocoReport, dependsOn: &quot;$testTaskName&quot;) {
              group = &quot;Reporting&quot;
              description = &quot;Generate Jacoco coverage reports for the ${name.capitalize()} build.&quot;
  
              classDirectories.from = fileTree(
                      dir: &quot;${project.buildDir}/intermediates/classes/${name}&quot;,
                      excludes: ['**/R.class',
                                 '**/R$*.class',
                                 '**/*$ViewInjector*.*',
                                 '**/*$ViewBinder*.*',
                                 '**/BuildConfig.*',
                                 '**/Manifest*.*']
              )
  
              sourceDirectories.from = files(['src/main/java'].plus(android.sourceSets[name].java.srcDirs))
              executionData.from = files(&quot;${project.buildDir}/jacoco/${testTaskName}.exec&quot;)
  
              reports {
                  xml.enabled = true
                  html.enabled = true
              }
          }
      }
  }
  </code></pre>
  <p>While running test cases through CL/Run(Button) or Jenkins, getting same error</p>
  <pre><code>com.example.LoginActivityTest &gt; initializationError FAILED
      java.lang.RuntimeException at AndroidJUnit4.java:121
          Caused by: java.lang.reflect.InvocationTargetException at null:-1
              Caused by: java.lang.NoSuchMethodError at ShadowProviders.java:25
  
  com.example.HomeActivityTest &gt; initializationError FAILED
      java.lang.RuntimeException at AndroidJUnit4.java:121
          Caused by: java.lang.reflect.InvocationTargetException at null:-1
              Caused by: java.lang.NoSuchMethodError at ShadowProviders.java:25
  
  
  
  =*=*=*=*=*=*=*=*=*=*
  
  java.lang.NoSuchMethodError: com.google.common.collect.ImmutableList.sortedCopyOf(Ljava/util/Comparator;Ljava/lang/Iterable;)Lcom/google/common/collect/ImmutableList;
  
      at org.robolectric.internal.bytecode.ShadowProviders.&lt;init&gt;(ShadowProviders.java:25)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
      at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
      at org.robolectric.util.inject.Injector.inject(Injector.java:250)
      at org.robolectric.util.inject.Injector.lambda$memoized$1(Injector.java:232)
      at org.robolectric.util.inject.Injector$MemoizingProvider.get(Injector.java:498)
      at org.robolectric.util.inject.Injector.getInstanceInternal(Injector.java:224)
      at org.robolectric.util.inject.Injector.getInstance(Injector.java:208)
      at org.robolectric.util.inject.Injector.getInstance(Injector.java:202)
      at org.robolectric.internal.SandboxTestRunner.&lt;init&gt;(SandboxTestRunner.java:78)
      at org.robolectric.RobolectricTestRunner.&lt;init&gt;(RobolectricTestRunner.java:103)
      at org.robolectric.RobolectricTestRunner.&lt;init&gt;(RobolectricTestRunner.java:98)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
      at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
      at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:104)
      at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:86)
      at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
      at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26)
      at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
      at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:33)
      at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:49)
      at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
      at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:230)
      at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:58)
  
  
  
  
  
  
  </code></pre>
  <p>I appreciate your help!</p>