title: Unable to instrument file: java.lang.NoClassDefFoundError android/content/ComponentCallbacks
body: <p>I am trying to generate Cobertura coverage reports for the (multi module) Android project I'm working on.
  The project was already there when I started implementing code coverage. The app that is the result of this project runs fine on all used devices. </p>
  
  <p>We start Gradle tasks from the command line, so that we can also execute them on our Jenkins CI server.
  The command I run is: </p>
  
  <pre><code>gradlew clean cobertura testDebug checkDebug assembleRelease
  </code></pre>
  
  <p>I've also tried different orders of commands. It did not help very much. 
  The other cobertura commands described in Usage.md did not help either.</p>
  
  <p>The Cobertura process runs well until the task :app:instrument starts to run.
  After a short while multiple NoClassDefFoundError are thrown.
  It results in a zero percent coverage for the classes involved, for instance my MainActivity class.
  A lot of error messages pop up. Please see the stacktrace:</p>
  
  <pre><code>:app:compileDebugAidl                 
  :app:compileDebugRenderscript                 
  :app:generateDebugBuildConfig                 
  :app:mergeDebugShaders                 
  :app:compileDebugShaders                 
  :app:generateDebugAssets                 
  :app:mergeDebugAssets                 
  :app:generateDebugResValues UP-TO-DATE      
  :app:generateDebugResources                 
  :app:mergeDebugResources                 
  :app:processDebugManifest                 
  :app:processDebugResources                 
  :app:generateDebugSources                 
  :app:incrementalDebugJavaCompilationSafeguard                 
  :app:compileDebugJavaWithJavac                 
  :app:compileDebugJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
  Note: Some input files use unchecked or unsafe operations.
  Note: Recompile with -Xlint:unchecked for details.
  :app:incrementalDebugUnitTestJavaCompilationSafeguard UP-TO-DATE      
  :app:preDebugUnitTestBuild UP-TO-DATE      
  :app:prepareDebugUnitTestDependencies                 
  :app:compileDebugUnitTestJavaWithJavac                 
  :app:compileDebugUnitTestJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
  :app:processDebugJavaRes UP-TO-DATE                    
  :app:processDebugUnitTestJavaRes                 
  :app:compileDebugUnitTestSources                 
  :app:mockableAndroidJar UP-TO-DATE      
  :app:assembleDebugUnitTest                 
  :app:instrument                                                              
  Cobertura 2.1.1 - GNU GPL License (NO WARRANTY) - See COPYRIGHT file
  Unable to instrument file C:\Code\Android\PhilipsPolaris\app\build\instrumented_classes\com\philips\polaris\activity\MainActivity.class
  java.lang.NoClassDefFoundError: android/content/ComponentCallbacks
          at java.lang.ClassLoader.defineClass1(Native Method)
          at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
          at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
          at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
          at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
          at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
          at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
          at java.security.AccessController.doPrivileged(Native Method)
          at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
          at java.lang.ClassLoader.defineClass1(Native Method)
          at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
          at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
          at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
          at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
          at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
          at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
          at java.security.AccessController.doPrivileged(Native Method)
          at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
          at java.lang.ClassLoader.defineClass1(Native Method)
          at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
          at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
          at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
          at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
          at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
          at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
          at java.security.AccessController.doPrivileged(Native Method)
          at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
          at java.lang.Class.forName0(Native Method)
          at java.lang.Class.forName(Class.java:348)
          at net.sourceforge.cobertura.instrument.CoberturaClassWriter.getCommonSuperClass(CoberturaClassWriter.java:32)
          at org.objectweb.asm.ClassWriter.a(Unknown Source)
          at org.objectweb.asm.Frame.a(Unknown Source)
          at org.objectweb.asm.Frame.a(Unknown Source)
          at org.objectweb.asm.MethodWriter.visitMaxs(Unknown Source)
          at org.objectweb.asm.MethodVisitor.visitMaxs(Unknown Source)
          at org.objectweb.asm.util.CheckMethodAdapter.visitMaxs(Unknown Source)
          at org.objectweb.asm.MethodVisitor.visitMaxs(Unknown Source)
          at org.objectweb.asm.commons.LocalVariablesSorter.visitMaxs(Unknown Source)
          at org.objectweb.asm.tree.MethodNode.accept(Unknown Source)
          at org.objectweb.asm.util.CheckMethodAdapter$1.visitEnd(Unknown Source)
          at org.objectweb.asm.MethodVisitor.visitEnd(Unknown Source)
          at org.objectweb.asm.util.CheckMethodAdapter.visitEnd(Unknown Source)
          at org.objectweb.asm.ClassReader.b(Unknown Source)
          at org.objectweb.asm.ClassReader.accept(Unknown Source)
          at org.objectweb.asm.ClassReader.accept(Unknown Source)
          at net.sourceforge.cobertura.instrument.CoberturaInstrumenter.instrumentClass(CoberturaInstrumenter.java:214)
          at net.sourceforge.cobertura.instrument.CoberturaInstrumenter.instrumentClass(CoberturaInstrumenter.java:129)
          at net.sourceforge.cobertura.instrument.CoberturaInstrumenter.addInstrumentationToSingleClass(CoberturaInstrumenter.java:243)
          at net.sourceforge.cobertura.instrument.CodeInstrumentationTask.addInstrumentationToSingleClass(CodeInstrumentationTask.java:299)
          at net.sourceforge.cobertura.instrument.CodeInstrumentationTask.addInstrumentation(CodeInstrumentationTask.java:308)
          at net.sourceforge.cobertura.instrument.CodeInstrumentationTask.addInstrumentation(CodeInstrumentationTask.java:317)
          at net.sourceforge.cobertura.instrument.CodeInstrumentationTask.addInstrumentation(CodeInstrumentationTask.java:317)
          at net.sourceforge.cobertura.instrument.CodeInstrumentationTask.addInstrumentation(CodeInstrumentationTask.java:317)
          at net.sourceforge.cobertura.instrument.CodeInstrumentationTask.addInstrumentation(CodeInstrumentationTask.java:317)
          at net.sourceforge.cobertura.instrument.CodeInstrumentationTask.addInstrumentation(CodeInstrumentationTask.java:317)
          at net.sourceforge.cobertura.instrument.CodeInstrumentationTask.instrument(CodeInstrumentationTask.java:90)
          at net.sourceforge.cobertura.dsl.Cobertura.instrumentCode(Cobertura.java:74)
          at net.sourceforge.cobertura.instrument.InstrumentMain.instrument(InstrumentMain.java:82)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          at java.lang.reflect.Method.invoke(Method.java:497)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          at java.lang.reflect.Method.invoke(Method.java:497)
          at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoCachedMethodSite.invoke(PojoMetaMethodSite.java:192)
          at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:56)
          at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
          at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
          at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:133)
          at net.saliman.gradle.plugin.cobertura.CoberturaRunner.executeCobertura(CoberturaRunner.groovy:224)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          at java.lang.reflect.Method.invoke(Method.java:497)
          at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:210)
          at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:59)
          at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:52)
          at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:154)
          at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:190)
          at net.saliman.gradle.plugin.cobertura.CoberturaRunner.instrument(CoberturaRunner.groovy:89)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          at java.lang.reflect.Method.invoke(Method.java:497)
          at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSite.invoke(PogoMetaMethodSite.java:169)
          at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.call(PogoMetaMethodSite.java:71)
          at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
          at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
          at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:149)
          at net.saliman.gradle.plugin.cobertura.InstrumentTask.instrument(InstrumentTask.groovy:145)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          at java.lang.reflect.Method.invoke(Method.java:497)
          at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:75)
          at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.doExecute(AnnotationProcessingTaskFactory.java:227)
          at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:220)
          at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:209)
          at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:585)
          at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:568)
          at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
          at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
          at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
          at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)
          at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:64)
          at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
          at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:52)
          at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
          at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53)
          at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
          at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:203)
          at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:185)
          at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:66)
          at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:50)
          at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:25)
          at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:110)
          at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:37)
          at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37)
          at org.gradle.execution.DefaultBuildExecuter.access$000(DefaultBuildExecuter.java:23)
          at org.gradle.execution.DefaultBuildExecuter$1.proceed(DefaultBuildExecuter.java:43)
          at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)
          at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37)
          at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:30)
          at org.gradle.initialization.DefaultGradleLauncher$4.run(DefaultGradleLauncher.java:154)
          at org.gradle.internal.Factories$1.create(Factories.java:22)
          at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
          at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:52)
          at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:151)
          at org.gradle.initialization.DefaultGradleLauncher.access$200(DefaultGradleLauncher.java:32)
          at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:99)
          at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:93)
          at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
          at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:62)
          at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:93)
          at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:82)
          at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:94)
          at org.gradle.tooling.internal.provider.ExecuteBuildActionRunner.run(ExecuteBuildActionRunner.java:28)
          at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
          at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:43)
          at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:28)
          at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:78)
          at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:48)
          at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSuggestingBuildActionExecuter.java:51)
          at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSuggestingBuildActionExecuter.java:28)
          at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:43)
          at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:170)
          at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:237)
          at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:210)
          at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:35)
          at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:24)
          at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:206)
          at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:169)
          at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
          at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
          at org.gradle.launcher.Main.doAction(Main.java:33)
          at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          at java.lang.reflect.Method.invoke(Method.java:497)
          at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:54)
          at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:35)
          at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          at java.lang.reflect.Method.invoke(Method.java:497)
          at org.gradle.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:33)
          at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:130)
          at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:48)
  Caused by: java.lang.ClassNotFoundException: android.content.ComponentCallbacks
          at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
          ... 178 more            
  Unable to instrument file C:\Code\Android\PhilipsPolaris\app\build\instrumented_classes\com\philips\polaris\activity\SplashActivity$1.class
  java.lang.RuntimeException: java.lang.ClassNotFoundException: android.content.Intent
          at net.sourceforge.cobertura.instrument.CoberturaClassWriter.getCommonSuperClass(CoberturaClassWriter.java:35)
          at org.objectweb.asm.ClassWriter.a(Unknown Source)
          at org.objectweb.asm.Frame.a(Unknown Source)
          at org.objectweb.asm.Frame.a(Unknown Source)         
  :app:copyCoberturaDatafile                 
  :app:testDebugUnitTest                                       
  [INFO] Cobertura: Loaded information on 179 classes.         
  [INFO] Cobertura: Saved information on 179 classes.          
  :app:cobertura                                               
  :app:generateCoberturaReport                 
  Cobertura 2.1.1 - GNU GPL License (NO WARRANTY) - See COPYRIGHT file
  Report time: 649ms                           
  :app:performCoverageCheck SKIPPED                     
  
  BUILD SUCCESSFUL
  
  Total time: 3 mins 51.432 secs
  </code></pre>
  
  <p>I think the problem is similar to issue #100.</p>
  
  <p>PROJECT.GRADLE</p>
  
  <pre><code>buildscript {
      repositories {
          jcenter()
          mavenCentral()
      }
      dependencies {
          classpath 'com.android.tools.build:gradle:2.1.0'
          classpath "net.saliman:gradle-cobertura-plugin:2.3.1"
  
          // NOTE: Do not place your application dependencies here; they belong
          // in the individual module build.gradle files
      }
  }
  
  allprojects {
      repositories {
          jcenter()
          mavenCentral()
      }
  }
  
  BUILD.GRADLE (app module)
  android {
      dexOptions {
          incremental true
          javaMaxHeapSize "4g"
      }
      packagingOptions {
          exclude 'LICENSE.txt'
          exclude 'META-INF/DEPENDENCIES.txt'
          exclude 'META-INF/LICENSE.txt'
          exclude 'META-INF/NOTICE.txt'
          exclude 'META-INF/NOTICE'
          exclude 'META-INF/LICENSE'
          exclude 'META-INF/DEPENDENCIES'
          exclude 'META-INF/notice.txt'
          exclude 'META-INF/license.txt'
          exclude 'META-INF/dependencies.txt'
          exclude 'META-INF/LGPL2.1'
      }
      compileSdkVersion 23
      buildToolsVersion '23.0.3'
      compileOptions.encoding = 'ISO-8859-1'
  
      defaultConfig {
          applicationId "com.my.app"
          minSdkVersion 14
          targetSdkVersion 23
          versionCode 31
          versionName "0.21.1"
          multiDexEnabled true
          testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
          renderscriptTargetApi 14
          renderscriptSupportModeEnabled true
          generatedDensities = []
      }
  
      buildTypes {
          release {
              minifyEnabled false
              proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
          }
          debug {
              debuggable true
              minifyEnabled false
              proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
              testCoverageEnabled true
          }
      }
  
      sourceSets {
          main {
              jniLibs.srcDirs = ["libs"]
          }
          test {
              jniLibs.srcDirs = ["libs"]
          }
      }
  
      lintOptions {
          abortOnError false
      }
  }
  
  cobertura {
      coverageFormats  = ['html']
      coverageIncludes = ['.*com.my.app.*']
      coverageExcludes = [
              ".*com.my.app.shadows.*",
              ".*\\.package-info.*",
              ".*\\.R.*",
              ".*BuildConfig.*",
              ".*Manifest.*"
      ]
      androidVariant = "debug"
  //    auxiliaryClasspath = files(new File("$buildDir/intermediates/classes/debug"))
  }
  
  repositories {
      mavenCentral()
      jcenter()
      maven { url "https://jitpack.io" }
  
      flatDir {
          dirs 'libs'
      }
  }
  
  dependencies {
      // Some dependencies (must obfuscate for client)
  
      // Robolectric
      testCompile('junit:junit:4.12') {
          exclude module: 'hamcrest-core'
      }
      testCompile 'org.robolectric:robolectric:3.0'
      testCompile 'org.robolectric:shadows-support-v4:3.0'
      testCompile 'org.robolectric:shadows-multidex:3.0'
  
      // Cobertura
      testCompile "org.slf4j:slf4j-api:1.7.10"
  }
  </code></pre>
  
  <p>I have tried many solutions I found scattered around the internet, but none of them seems to work.
  It seems that the Android SDK is not properly set up for the Cobertura process. 
  One thing I noticed is that the missing Android classes are all in the "android.content.x" package and the "org.json.x" package.
  Any support is welcome. Thanks.</p>