Android: 如何使用支持 25.0.0 的 Espresso 2.2.2?

Android: how to use Espresso 2.2.2 with Support 25.0.0?

我怎样才能让它工作?我看了很多类似的攻略,唉。使用高于 23.1.1 的支持库多次失败。

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'
 })
}

我收到这条消息:

Warning:Conflict 依赖 'com.android.support:recyclerview-v7'。应用程序 (25.0.0) 和测试应用程序 (23.1.1) 的已解决版本不同。有关详细信息,请参阅 http://g.co/androidstudio/app-test-app-conflict。 Warning:Conflict 具有依赖性 'com.android.support:support-v4'。应用程序 (25.0.0) 和测试应用程序 (23.1.1) 的已解决版本不同。有关详细信息,请参阅 http://g.co/androidstudio/app-test-app-conflict。 Warning:Conflict 具有依赖性 'com.android.support:appcompat-v7'。应用程序 (25.0.0) 和测试应用程序 (23.1.1) 的已解决版本不同。有关详细信息,请参阅 http://g.co/androidstudio/app-test-app-conflict。 Warning:Conflict 具有依赖性 'com.android.support:design'。应用程序 (25.0.0) 和测试应用程序 (23.1.1) 的已解决版本不同。有关详细信息,请参阅 http://g.co/androidstudio/app-test-app-conflict

第 1 步:我尝试使用排除组...没有用。

第 2 步:我还尝试了不同的策略,例如: configurations.all{ 分辨率策略{ 力 'com.android.support:support-annotations:23.1.1' } }

第 3 步:当然我首先尝试了 gradlew :app:dependenices 等,但是那个一直在崩溃。是的,我用的是JDK1.8。这是一个注册的错误,自夏天以来一直没有解决。

对了……Android,支持包和Espresso都来自Google?

尝试

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'
  }

这是我的工作设置 - 您基本上从所有 Espresso 依赖项中排除了支持注释,并让它们使用已从标准运行时依赖项中解析出来的注释。其他一些依赖项给我带来了麻烦,所以我也将它们排除在外,让构建从显式 compile 语句中解决它们。