Android: how to use Espresso 2.2.2 with Support 25.0.0?

南楼画角 提交于 2020-01-04 06:15:44

问题


How can I get this working? I read many similar strategies, alas. Using a support lib higher than 23.1.1 fails times and again.

dependencies {
  compile 'com.android.support:design:25.0.0'
  compile 'com.android.support:support-v4:25.0.0'
  compile files('libs/slf4j-android-1.5.8.jar')
  androidTestCompile 'com.android.support:support-annotations:25.0.0'
  androidTestCompile( 'com.android.support.test:rules:0.5')
  androidTestCompile( 'com.android.support.test.espresso:espresso-contrib:2.2.2')
  androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
 })
}

I got this message:

Warning:Conflict with dependency 'com.android.support:recyclerview-v7'. Resolved versions for app (25.0.0) and test app (23.1.1) differ. See http://g.co/androidstudio/app-test-app-conflict for details. Warning:Conflict with dependency 'com.android.support:support-v4'. Resolved versions for app (25.0.0) and test app (23.1.1) differ. See http://g.co/androidstudio/app-test-app-conflict for details. Warning:Conflict with dependency 'com.android.support:appcompat-v7'. Resolved versions for app (25.0.0) and test app (23.1.1) differ. See http://g.co/androidstudio/app-test-app-conflict for details. Warning:Conflict with dependency 'com.android.support:design'. Resolved versions for app (25.0.0) and test app (23.1.1) differ. See http://g.co/androidstudio/app-test-app-conflict for details.

STEP 1: I tried with the exclude group... did not work.

STEP 2: I also tried different strategies like: configurations.all { resolutionStrategy { force 'com.android.support:support-annotations:23.1.1' } }

STEP 3: Of course I tried first gradlew :app:dependenices, etc, but that one keeps on crashing. Yes, I use JDK1.8. It is a registered bug that has not been solved since summer.

By the way ... Android, support package and Espresso are all from Google?


回答1:


Try

dependencies {
  compile 'com.android.support:design:25.0.0'
  compile 'com.android.support:support-v4:25.0.0'
  compile files('libs/slf4j-android-1.5.8.jar')
  androidTestCompile 'com.android.support:support-annotations:25.0.0'
  androidTestCompile('com.android.support.test:rules:0.5') {
               exclude module: 'support-annotations'
  }
  androidTestCompile('com.android.support.test.espresso:espresso-contrib:2.2.2') {
               exclude module: 'espresso-core'
               exclude module: 'support-v4'
               exclude module: 'recyclerview-v7'
               exclude module: 'appcompat-v7'
               exclude module: 'support-annotations'
               exclude module: 'design'
  }
  androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2') {
               exclude module: 'rules'
               exclude module: 'javax.annotation-api'
               exclude module: 'support-annotations'
  }

That's my working setup - you essentially exclude support annotations from all Espresso dependencies and let them use the one that's been resolved from your standard runtime dependencies. Some other dependencies caused me trouble so I just exclude them as well and let the build resolve them from explicit compile statements.



来源:https://stackoverflow.com/questions/40696796/android-how-to-use-espresso-2-2-2-with-support-25-0-0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!