43

UPDATE Oct 21, 2014: The issue has been confirmed as fixed by using buildtools 21.

UPDATE SEPT 18, 2014: The issue's status has been updated to FutureRelease.

UPDATE: I have heard that this may not work with Dagger, and since Espresso uses Dagger, it might be causing some issues. A bug was submitted to the Gradle team.


Google recently updated their Gradle implementation to 0.10.0. One of the things they now offer is Jacoco support. To do this, they mention setting the following:

testCoverageEnabled = true

Into your build type. Now when I run my Espresso tests (using connectedCheck), I get an error right as I start to run the :connectedAndroidTest task that states:

Tests on HTC One - 4.2.2 - API 17 - 1080x1920 - 4.2.2 failed: Instrumentation run failed due to 'java.lang.VerifyError'
01:38:31 E/Device: Error during Sync: Remote object doesn't exist!
null
java.io.IOException: com.android.ddmlib.SyncException: Remote object doesn't exist!
at com.android.builder.testing.ConnectedDevice.pullFile(ConnectedDevice.java:114)
at com.android.builder.internal.testing.SimpleTestCallable.call(SimpleTestCallable.java:158)
at com.android.builder.internal.testing.SimpleTestCallable.call(SimpleTestCallable.java:42)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Caused by: com.android.ddmlib.SyncException: Remote object doesn't exist!
at com.android.ddmlib.SyncService.pullFile(SyncService.java:314)
at com.android.ddmlib.Device.pullFile(Device.java:849)
at com.android.builder.testing.ConnectedDevice.pullFile(ConnectedDevice.java:107)
... 8 more
:connectedAndroidTest FAILED

Here are the parts I have changed in the build.gradle file:

buildscript {
    dependencies {
        classpath 'com.android.tools.build:gradle:0.10.+'
        ...
    }
    ...
}

android {
    buildTypes {
        debug {
            testCoverageEnabled = true
            ...
        }
        ....
    }
    ...
}

Is there any other piece of build.gradle file that I need to update in order to get Jacoco working?

The error mentions that a "remote object" doesn't exist. Usually I attribute this to the emulator being out of sync and a restart would fix it. But I've tried that and it isn't worked either. Any ideas what the error is trying to tell me?

Hamad
  • 5,096
  • 13
  • 37
  • 65
Maxwell
  • 6,532
  • 4
  • 37
  • 55
  • I'm running into the same exact issue (not using Dagger or Espresso). The tests run on a real device (Nexus 4, 4.3.1). I am seeing a ClassNotFoundException for CoverageTransformer (part of JaCoCo Agent) in logcat.. – friederbluemle May 01 '14 at 07:38
  • That's failing in the pullFile method, I think it's trying to pull a file that it doesn't have permission, try on an emulator (since it acts as a rooted device) and see if it can pull the file there. – Xavi Rigau May 01 '14 at 08:34
  • That was my first thought too, but I used a rooted device and restarted adb in root mode `adb root`, still seeing the same error. – friederbluemle May 01 '14 at 20:29
  • 1
    Did anyone find a solution to this? I am running into the same issue on both a rooted device and emulators. – Shane Doyle Jun 05 '14 at 16:20
  • I'm experiencing the same issue as well. Exact same exception; also on an HTC One. – dcow Jun 20 '14 at 17:15
  • 1
    Are you still facing this 0.12.2? – hoomi Aug 30 '14 at 11:11
  • See update. Looks like this will be available soon. – Maxwell Sep 18 '14 at 16:21

1 Answers1

1

Try This One...

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.13.0'
    }
}

repositories {
    mavenCentral()
}
apply plugin: 'com.android.application'
apply plugin: 'jacoco'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.1" // Must Require

    defaultConfig {
        applicationId "com.packagename" <Change it>
        minSdkVersion 11
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"

    }

    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/services/javax.annotation.processing.Processor'
    }

    lintOptions {
        abortOnError false
    }

    buildTypes {
        debug {
            testCoverageEnabled true
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
}

jacoco {
    toolVersion = "0.7.1.201405082137"
}
Nilesh Senta
  • 5,236
  • 2
  • 19
  • 27