Why would adding espresso-contrib cause an InflateException?

后端 未结 3 894
日久生厌
日久生厌 2020-12-14 07:23

In my build.gradle file I have the support library dependencies:

compile \"com.android.support:appcompat-v7:22.2.0\"
compile \"com.android.support:recyclervi         


        
相关标签:
3条回答
  • 2020-12-14 08:13

    Try this:

    // Testing dependencies
    androidTestCompile 'com.android.support.test:runner:0.4.1'
    androidTestCompile 'com.android.support.test:rules:0.4.1'
    androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.1'
    androidTestCompile 'com.android.support.test.espresso:espresso-intents:2.2.1'
        androidTestCompile('com.android.support.test.espresso:espresso-contrib:2.2.1') {
            exclude group: 'com.android.support', module: 'appcompat'
            exclude group: 'com.android.support', module: 'support-v4'
            exclude module: 'support-annotations'
            exclude module: 'recyclerview-v7'
        }
    
    0 讨论(0)
  • 2020-12-14 08:14

    Try this in your build.gradle:

    androidTestCompile ('com.android.support.test.espresso:espresso-contrib:2.2'){
        exclude group: 'com.android.support', module: 'appcompat-v7'
        exclude group: 'com.android.support', module: 'support-v4'
        exclude module: 'recyclerview-v7'
    }
    
    0 讨论(0)
  • 2020-12-14 08:17

    I have the same problem about error inflating class recycler view, and tried several times with various codes, finally i resolved this problem with added these codes in project gradle:

     androidTestCompile 'com.android.support.test.espresso:espresso-intents:2.2.1'
    androidTestCompile ('com.android.support.test.espresso:espresso-core:2.2.1') {
        exclude module: 'support-annotations'
    }
    androidTestCompile ('com.android.support.test.espresso:espresso-contrib:2.2.1') {
        exclude module: 'support-annotations'
        exclude module: 'support-v4'
        exclude module: 'recyclerview-v7'
    }
    

    Secondly, you have to make sure you're using card view and recycler view in the latest version:

    compile 'com.android.support:cardview-v7:23.1.1'
    compile 'com.android.support:recyclerview-v7:23.1.1'
    

    Then you can run your test which has recycler view in it's activity layout. It'll work fine and no error happens again.

    0 讨论(0)
提交回复
热议问题