可以与v7 recyclerview兼容的Espresso Androidx吗?

时间:2018-11-09 06:57:59

标签: android android-recyclerview android-appcompat android-espresso androidx

我的应用的Reyclerview是“ android.support.v7.widget.RecyclerView” 我用的是androidx的意式浓缩咖啡。

我向我的gradle中添加了依赖项,如下所示:

androidTestImplementation 'androidx.annotation:annotation:' + rootProject.androidxLibVersion;
androidTestImplementation 'androidx.recyclerview:recyclerview:' + rootProject.androidxLibVersion;
androidTestImplementation 'androidx.test:core:' + rootProject.coreVersion
androidTestImplementation 'androidx.test.ext:junit:' + rootProject.extJUnitVersion
androidTestImplementation 'androidx.test:runner:' + rootProject.runnerVersion
androidTestImplementation 'androidx.test.espresso:espresso-core:' + rootProject.espressoVersion
androidTestImplementation 'androidx.test.espresso:espresso-contrib:' + rootProject.espressoVersion
androidTestImplementation 'androidx.test.espresso:espresso-intents:' + rootProject.espressoVersion

但是,当我尝试使用

import androidx.recyclerview.widget.RecyclerView
import androidx.test.espresso.contrib.RecyclerViewActions

    ...

RecyclerViewActions.scrollToPosition<RecyclerView.ViewHolder>(position)

它说

  

由于:java.lang.RuntimeException:将不执行操作   因为目标视图与以下一项或多项不匹配   约束:(可从类:类分配   androidx.recyclerview.widget.RecyclerView并显示在   屏幕显示给用户)目标视图:“ RecyclerView {id = 2131296674,   res-name = media_content_recyclerview,可见度= VISIBLE,宽度= 1440,   高度= 2384,has-focus = false,has-focusable = true,   has-window-focus = true,is-clickable = false,is-enabled = true,   is-focused = false,is-focusable = true,is-layout-requested = false,   is-selected = false,   layout-params=android.widget.RelativeLayout$LayoutParams@e32b046,   tag = null,root-is-layout-requested = false,has-input-connection = false,   x = 0.0,y = 192.0,child-count = 15}“

我的代码有什么问题吗?

0 个答案:

没有答案