Android Espresso Issue - Dependency conflict

前端 未结 8 1884
Happy的楠姐
Happy的楠姐 2021-02-12 16:34

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

dependencies {
    compile fileTree(dir: \'libs\', inclu         


        
8条回答
  •  伪装坚强ぢ
    2021-02-12 17:04

    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

提交回复
热议问题