2016-12-05 40 views
1

我需要为我的android应用开发仪器测试,并且我还需要将接口IdlingResource实现到我的应用,以便告诉Espresso该活动处于空闲状态;所以我必须添加咖啡相依两次,一次在正常编译,一个在测试编译,看起来像这样:在普通和测试编辑中添加了Espresso依赖关系

dependencies { 
    compile fileTree(include: ['*.jar'], dir: 'libs') 
    [...] 
    compile('com.android.support.test.espresso:espresso-core:2.2.2') { 
     exclude module: 'support-annotations' 
    } 
    androidTestCompile('com.android.support.test:runner:0.5') { 
     exclude module: 'support-annotations' 
    } 
    androidTestCompile('com.android.support.test:rules:0.5') { 
     exclude module: 'support-annotations' 
    } 
    // The following lib is already imported in a standard way, but needs to be imported again 
    // in the test environment. 
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2') { 
     exclude module: 'support-annotations' 
    } 
    androidTestCompile('com.android.support.test.espresso:espresso-intents:2.2.2') { 
     exclude module: 'support-annotations' 
    } 
    [...] 
} 

但是做应用程序的正常编译不起作用:

Error:Execution failed for task ':app:processDebugAndroidTestResources'. 
> java.io.FileNotFoundException: [...]/app/build/intermediates/symbols/androidTest/debug/R.txt (No such file or directory) 

我做错了什么?

回答

2

build.gradle删除:

compile('com.android.support.test.espresso:espresso-core:2.2.2') { 
     exclude module: 'support-annotations' 
} 

this,您需要添加compile 'com.android.support.test.espresso:espresso-idling-resource:2.2.2'而不是整个咖啡核LIB的。