Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Espresso Issue - Dependency conflict

I'm trying to integrate espresso into my application for ui testing. Here are my dependencies in Gradle

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.2.0'
    compile 'com.android.support:design:22.2.1'
    compile 'com.github.bumptech.glide:okhttp-integration:1.3.1@aar'
    compile 'com.squareup.okhttp:okhttp:2.0.0'
    compile 'de.hdodenhof:circleimageview:1.3.0'
    compile 'com.android.support:cardview-v7:21.+'
    compile 'com.android.support:recyclerview-v7:21.+'
    androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2'
    androidTestCompile 'com.android.support.test.espresso:espresso-contrib:2.2'
    compile 'com.android.support:support-annotations:22.2.0'
    androidTestCompile 'com.android.support.test:runner:0.3'
    compile project(':common')
    compile project(':service')
}

So all my espresso dependencies are included. However when I try to build I get this error:

Warning:Conflict with dependency 'com.android.support:support-annotations'. Resolved versions for app (22.2.1) and test app (22.2.0) differ.

Has anyone encountered this? I've found it reported here however there's no resolution. Does anyone have a fix for this?

like image 249
DJ-DOO Avatar asked Aug 04 '15 10:08

DJ-DOO


1 Answers

New version of espresso-contrib 2.2.2 library has now dependency on com.android.support:appcompat-v7:23.1.1 resulting into conflict when using different version of appcompat-v7 in our compile time dependency like below:

dependencies {
     compile fileTree(dir: 'libs', include: ['*.jar'])
     testCompile 'junit:junit:4.12'
     compile 'com.android.support:appcompat-v7:23.4.0'

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

To avoid conflict when we exclude appcompat-v7 dependency from espresso-contrib like below it breaks again due to some value dependencies on design support lib.

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

Error:

Error:(69) Error retrieving parent for item: No resource found that matches the given name 'TextAppearance.AppCompat.Display1'.

So, the solution to above problem is to exclude 'design-support' lib depedency from espresso-contrib like below:

androidTestCompile ('com.android.support.test.espresso:espresso-contrib:2.2.2'){
    exclude module: 'support-annotations'
    exclude module: 'support-v4'
    exclude module: 'support-v13'
    exclude module: 'recyclerview-v7'
    exclude module: 'design'
}

That solves the conflict problem!

For more detailed version of the answer you could check my other answer

like image 198
PunitD Avatar answered Oct 12 '22 17:10

PunitD