Why would adding espresso-contrib cause an InflateException?

后端 未结 3 898
日久生厌
日久生厌 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: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.

提交回复
热议问题