我想學習android espresso ..我遵循一些基本教程,它工作正常。但現在我想對android導航抽屜做一些測試。爲此,我需要使用gradle dependency androidTestCompile'com.android.support.test.espresso:espresso-contrib:2.2.2'但它與其他依賴項產生衝突。我gradle這個文件:安卓espresso-cotrib gradle構建失敗
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "my.com.myapp_android"
minSdkVersion 18
targetSdkVersion 23
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
jcenter()
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
//material design
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.android.support:support-v4:23.3.0'
//zxing
compile 'com.journeyapps:zxing-android-embedded:[email protected]'
compile 'com.google.zxing:core:3.2.1'
//Testing
// Optional -- Mockito framework
testCompile 'org.mockito:mockito-core:1.10.19'
androidTestCompile 'com.android.support:support-annotations:23.3.0'
androidTestCompile 'com.android.support.test:runner:0.5'
androidTestCompile 'com.android.support.test:rules:0.4.1'
// Optional -- Hamcrest library
androidTestCompile 'org.hamcrest:hamcrest-library:1.3'
// Optional -- UI testing with Espresso
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
androidTestCompile 'com.android.support.test.espresso:espresso-contrib:2.2.2'
// Optional -- UI testing with UI Automator
androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.1'
//inMarketSDK
//compile group: 'com.inmarket', name: 'm2msdk', version: '2.29', ext: 'aar'
}
錯誤是這樣的:
Error:Conflict with dependency 'com.android.support:support-v4'. Resolved versions for app (23.3.0) and test app (23.1.1) differ. See http://g.co/androidstudio/app-test-app-conflict for details.
Error:Conflict with dependency 'com.android.support:appcompat-v7'. Resolved versions for app (23.3.0) and test app (23.1.1) differ. See http://g.co/androidstudio/app-test-app-conflict for details.
遵循這樣的:link的咖啡安裝
我也試圖排除註釋依賴性:
androidTestCompile ('com.android.support.test.espresso:espresso-core:2.2.2') {
// Necessary if your app targets Marshmallow (since Espresso
// hasn't moved to Marshmallow yet)
exclude group: 'com.android.support', module: 'support-annotations'
}
androidTestCompile ('com.android.support.test.espresso:espresso-contrib:2.2.2')
{
// Necessary if your app targets Marshmallow (since Espresso
// hasn't moved to Marshmallow yet)
exclude group: 'com.android.support', module: 'support-annotations'
}
錯誤消息說與'com.android.support:support-v4'和'com.android.support:appcompat-v7'衝突。所以儘量排除它們。 – nenick