rha*_*ari 3 android gradle android-studio android-espresso
我正在尝试将espresso-contrib库添加到我的项目中.这是我的build.gradle文件:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "example.com.littlebox_hari"
minSdkVersion 19
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'
}
}
/*configurations.all {
resolutionStrategy {
force 'com.android.support:appcompat-v7:23.4.0'
}
}*/
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.squareup.retrofit2:retrofit:2.0.0'
compile 'com.squareup.retrofit2:converter-gson:2.0.0'
androidTestCompile 'com.android.support.test:runner:0.4'
androidTestCompile 'com.android.support.test:rules:0.4'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.1'
androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.2'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.1'
androidTestCompile 'com.android.support.test.espresso:espresso-contrib:2.2.2'
androidTestCompile 'com.android.support.test.espresso:espresso-idling-resource:2.2.2'
compile 'com.android.support:support-annotations:23.4.0'
testCompile 'com.android.support:support-annotations:23.4.0'
androidTestCompile 'com.android.support:support-annotations:23.4.0'
}
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
Error:Conflict with dependency 'com.android.support:appcompat-v7'. Resolved versions for app (23.4.0) and test app (23.1.1) differ. See http://g.co/androidstudio/app-test-app-conflict for details.
Run Code Online (Sandbox Code Playgroud)
如果我取消注释build.gradle文件中的行,我得到:
Error:(72) Error retrieving parent for item: No resource found that matches the given name 'TextAppearance.AppCompat.Display1'.
Error:(75) Error retrieving parent for item: No resource found that matches the given name 'TextAppearance.AppCompat.Caption'.
Error:(79) Error retrieving parent for item: No resource found that matches the given name 'TextAppearance.AppCompat.Caption'.
Error:(76) Error retrieving parent for item: No resource found that matches the given name 'TextAppearance.AppCompat.Caption'.
Error:(82) Error retrieving parent for item: No resource found that matches the given name 'TextAppearance.AppCompat.Caption'.
Error:(89) Error retrieving parent for item: No resource found that matches the given name 'TextAppearance.AppCompat.Button'.
D:\Littlebox-Hari\app\build\intermediates\exploded-aar\com.android.support\design\23.1.1\res\values\values.xml
Error:(97, 5) No resource found that matches the given name: attr 'textAllCaps'.
Error:(102, 5) No resource found that matches the given name: attr 'elevation'.
Error:(113, 5) No resource found that matches the given name: attr 'backgroundTint'.
Error:(113, 5) No resource found that matches the given name: attr 'elevation'.
Error:(122, 5) No resource found that matches the given name: attr 'elevation'.
Error:(131, 5) No resource found that matches the given name: attr 'elevation'.
Run Code Online (Sandbox Code Playgroud)
编辑:我在build.gradle文件中添加了以下行:
testCompile 'com.android.support:appcompat-v7:23.4.0'
androidTestCompile 'com.android.support:appcompat-v7:23.4.0'
Run Code Online (Sandbox Code Playgroud)
我仍然得到同样的错误.
Rúb*_*usa 16
我今天也遇到了这个问题.
首先,将依赖项更新为其最新版本(0.5和2.2.2).
请参阅:https://google.github.io/android-testing-support-library/downloads/
// Android JUnit Runner
androidTestCompile 'com.android.support.test:runner:0.5'
// JUnit4 Rules
androidTestCompile 'com.android.support.test:rules:0.5'
// Espresso core
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
// Espresso-contrib for DatePicker, RecyclerView, Drawer actions, Accessibility checks, CountingIdlingResource
androidTestCompile 'com.android.support.test.espresso:espresso-contrib:2.2.2'
// Espresso-web for WebView support
androidTestCompile 'com.android.support.test.espresso:espresso-web:2.2.2'
// Espresso-idling-resource for synchronization with background jobs
androidTestCompile 'com.android.support.test.espresso:espresso-idling-resource:2.2.2'
Run Code Online (Sandbox Code Playgroud)
然后,您将面临同样的错误,因为最新版本目前尚未使用最新版本的支持库(23.4.0).已经在错误跟踪器上打开了一个问题:https://code.google.com/p/android/issues/detail?id = 211490
这对我有用:
dependencies {
ext {
supportLibVersion = '23.4.0'
espressoVersion = '2.2.2'
}
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
androidTestCompile 'com.android.support.test:runner:0.5'
androidTestCompile 'com.android.support.test:rules:0.5'
androidTestCompile "com.android.support.test.espresso:espresso-core:$espressoVersion"
androidTestCompile ("com.android.support.test.espresso:espresso-contrib:$espressoVersion") {
exclude module: 'recyclerview-v7'
exclude module: 'design'
}
androidTestCompile "com.android.support.test.espresso:espresso-web:$espressoVersion"
androidTestCompile "com.android.support.test.espresso:espresso-idling-resource:$espressoVersion"
androidTestCompile "com.android.support:support-annotations:$supportLibVersion"
compile "com.android.support:appcompat-v7:$supportLibVersion"
compile "com.android.support:design:$supportLibVersion"
compile "com.android.support:appcompat-v7:$supportLibVersion"
compile "com.android.support:recyclerview-v7:$supportLibVersion"
}
Run Code Online (Sandbox Code Playgroud)
编辑: 根据此代码路径指南,似乎这是正确的方法:
ext {
supportLibVersion = '24.1.1'
espressoVersion = '2.2.2'
junitVersion = '4.12'
mockitoVersion = '1.10.19'
hamcrestVersion = '1.3'
powerMockitoVersion = '1.6.5'
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile "com.android.support:appcompat-v7:$supportLibVersion"
compile "com.android.support:design:$supportLibVersion"
compile "com.android.support:recyclerview-v7:$supportLibVersion"
// Testing dependencies
testCompile "junit:junit:$junitVersion"
testCompile "org.mockito:mockito-all:$mockitoVersion"
testCompile "org.hamcrest:hamcrest-all:$hamcrestVersion"
testCompile "org.powermock:powermock-module-junit4:$powerMockitoVersion"
testCompile "org.powermock:powermock-api-mockito:$powerMockitoVersion"
androidTestCompile 'com.android.support.test:runner:0.5'
androidTestCompile 'com.android.support.test:rules:0.5'
androidTestCompile "com.android.support.test.espresso:espresso-core:$espressoVersion"
androidTestCompile "com.android.support.test.espresso:espresso-contrib:$espressoVersion"
androidTestCompile "com.android.support.test.espresso:espresso-web:$espressoVersion"
androidTestCompile "com.android.support.test.espresso:espresso-idling-resource:$espressoVersion"
}
configurations.all {
resolutionStrategy.force "com.android.support:support-annotations:$supportLibVersion"
}
configurations.compile.dependencies.each { compileDependency ->
println "Excluding compile dependency: ${compileDependency.getName()}"
configurations.androidTestCompile.dependencies.each { androidTestCompileDependency ->
configurations.androidTestCompile.exclude module: "${compileDependency.getName()}"
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2948 次 |
| 最近记录: |