Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jacoco with Gradle 0.10.0: Remote object doesn't exist

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?

like image 738
Maxwell Avatar asked Apr 30 '14 19:04

Maxwell


1 Answers

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"
}
like image 168
Nilesh Senta Avatar answered Oct 13 '22 18:10

Nilesh Senta