【问题标题】:Error:Conflict with dependency 'com.android.support:support-v4' in project ':app'. Resolved versions for app (25.3.1) and test app (23.1.1) differ错误:与项目“:app”中的依赖项“com.android.support:support-v4”冲突。应用程序 (25.3.1) 和测试应用程序 (23.1.1) 的已解决版本不同
【发布时间】:2017-11-20 07:42:39
【问题描述】:

每次我尝试通过以下依赖项添加 Esspreso UI 测试库的依赖项以使用它为 RecyclerView 开发 UI 测试以获取 RecyclerViewActions 时,都会收到此错误。

 androidTestCompile 'com.android.support.test.espresso:espresso-contrib:2.2.2'

虽然删除以前的依赖 gradle 正在完美构建 谁能帮我解决这个问题?? 来自我的 gradle 的样本:

 dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
            exclude group: 'com.android.support', module: 'support-annotations'
        })
       compile 'com.android.support:appcompat-v7:25.3.1'
        compile 'com.android.support.constraint:constraint-layout:1.0.2'
        compile 'com.android.support:recyclerview-v7:25.3.1'
        compile 'com.android.support:cardview-v7:25.3.1'
        compile 'com.squareup.okhttp3:okhttp:3.6.0'
        compile 'com.github.bumptech.glide:glide:4.0.0-RC0'
        testCompile 'junit:junit:4.12'

        compile 'com.jakewharton:butterknife:8.6.0'
        annotationProcessor 'com.jakewharton:butterknife-compiler:8.6.0'
        annotationProcessor 'com.github.bumptech.glide:compiler:4.0.0-RC0'

        compile 'com.google.android.exoplayer:exoplayer:r2.2.0'

        androidTestCompile( 'com.android.support.test.espresso:espresso-intents:2.2.2', {
            exclude group: 'com.android.support', module: 'support-annotations'
        })
        androidTestCompile( 'com.android.support.test:rules:0.5', {
            exclude group: 'com.android.support', module: 'support-annotations'
        })
        androidTestCompile ('com.android.support.test:runner:0.5', {
            exclude group: 'com.android.support', module: 'support-annotations'
        })
        androidTestCompile ('com.android.support.test.espresso:espresso-web:2.2.2', {
            exclude group: 'com.android.support', module: 'support-annotations'
        })
        androidTestCompile( 'com.android.support.test.espresso:espresso-contrib:2.2.2', {
            exclude group: 'com.android.support', module: 'support-annotations'
        })

    }

更新

谷歌搜索一个小时后,我在Vogella 中找到了解决方案 将此依赖项设置如下:

androidTestCompile('com.android.support.test.espresso:espresso-contrib:2.2') {
        exclude group: 'com.android.support', module: 'appcompat'
        exclude group: 'com.android.support', module: 'support-v4'
        exclude group: 'com.android.support', module: 'support-annotations'
        exclude module: 'recyclerview-v7'
    }

【问题讨论】:

标签: android gradle android-espresso


【解决方案1】:

这将解决您的问题:

androidTestCompile('com.android.support.test.espresso:espresso-contrib:2.2.2') {
    exclude group: 'com.google.code.findbugs'
    exclude group: 'com.android.support', module: 'appcompat-v7'
    exclude group: 'com.android.support', module: 'support-v4'
    exclude group: 'com.android.support', module: 'design'
    exclude module: 'recyclerview-v7'
}

您只需排除您在build.gradle 中已经提供的每个库

【讨论】:

  • 这是我在谷歌搜索数小时后找到的相同解决方案,但使用的是:com.android.support.test.espresso:espresso-contrib:2.2 而不是 2.2.2
猜你喜欢
  • 1970-01-01
  • 2016-08-02
  • 2023-03-12
  • 2018-10-11
  • 1970-01-01
  • 2019-01-22
  • 2018-11-20
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多