user1796624 February 2016

Espresso test aren't running after adding espresso-contrib library in gradle

When I'm adding the

androidTestCompile ''

in the gradle and run an Espresso test, I get the following error:

 Testing started at 5:59 PM ...

02/08 17:59:58: Launching changeText_sameAct...()
No apk changes detected since last installation, skipping installation of /Users/xxx/Documents/home/MasterDetails/app/build/outputs/apk/app-debug.apk
$ adb shell am force-stop
No apk changes detected since last installation, skipping installation of /Users/xxx/Documents/home/MasterDetails/app/build/outputs/apk/app-debug-androidTest-unaligned.apk
$ adb shell am force-stop
Running tests

$ adb shell am instrument -w -r   -e debug false -e class
Client not ready yet..Waiting for process to come online
Connected to process 10355 on device samsung-sm_g920f-01157df1bc4b5336
Test running started

at dalvik.system.DexFile.defineClassNative(Native Method)
at dalvik.system.DexFile.defineClass(
at dalvik.system.DexFile.loadClassBinaryName(
at dalvik.system.DexPathList.findClass(
at dalvik.system.BaseDexClassLoader.findClass(
at java.lang.ClassLoader.loadClass(
at java.lang.ClassLoader.loadClass(
at java.lang.reflect.Constructor.newInstance(Native Method)
at java.lang.reflect.Constructor.newInstance(
at org.junit.runners.BlockJUnit4ClassRunner.createTest(
at org.junit.runners.BlockJUnit4ClassRunner$1.runReflec        


denys February 2016

Seems that you include RecyclerView component twice: here - compile '' and here androidTestCompile ''. Add below code in your build.gradle after dependencies section and try again:

configurations {
    androidTestCompile.exclude group: '', module: 'recyclerview-v7'

piotrek1543 February 2016

Please check my dependendecies, especially espresso ones.

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

    androidTestCompile "$ASVersion"
    androidTestCompile ''
    androidTestCompile ''
    androidTestCompile('') {
        exclude group: '', module: 'appcompat'
        exclude group: '', module: 'support-v4'
        exclude module: 'recyclerview-v7'
    androidTestCompile ''
    compile 'com.squareup.retrofit:retrofit:1.9.0'
    compile "$ASVersion"
    compile "$ASVersion"
    compile "$ASVersion"


where def ASVersion = '23.1.1'

Maybe you missed something. Mine already working

Hope it help

Post Status

Asked in February 2016
Viewed 3,654 times
Voted 13
Answered 2 times


Leave an answer