【问题标题】:Cannot Resolve Symbol RecyclerViewActions / RecyclerViewMatcher无法解决符号 RecyclerViewActions / RecyclerViewMatcher
【发布时间】:2020-05-23 22:31:54
【问题描述】:

我正在尝试在我的 android 应用程序中为回收站视图编写测试。我收到“RecyclerViewActions”和“RecyclerViewMatcher”的无法解析符号错误。

这是我的测试中抛出“无法解析符号”错误的辅助方法。

````// Convenience helper
public static RecyclerViewMatcher withRecyclerView(final int recyclerViewId) {
    return new RecyclerViewMatcher(recyclerViewId);
}````

这是我的导入,错误也被抛出

import static androidx.test.espresso.contrib.RecyclerViewActions;

这是我的应用级 build.gradle 依赖项:

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])

    implementation 'androidx.appcompat:appcompat:1.0.2'
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'androidx.recyclerview:recyclerview:1.1.0'
    implementation 'com.google.android.material:material:1.0.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'androidx.navigation:navigation-fragment:2.0.0'
    implementation 'androidx.navigation:navigation-ui:2.0.0'
    implementation 'androidx.coordinatorlayout:coordinatorlayout:1.1.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:rules:1.1.1'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
    androidTestImplementation('androidx.test.espresso:espresso-contrib:3.2.0') {
        exclude group: 'com.android.support', module: 'appcompat'
        exclude group: 'com.android.support', module: 'support-v4'
    }
}````

【问题讨论】:

    标签: java android


    【解决方案1】:

    在应用级 build.gradle 中添加:

    dependencies {
        implementation fileTree(dir: 'libs', include: ['*.jar'])
    
        implementation 'com.google.android.material:material:1.0.0'
    
        implementation 'androidx.appcompat:appcompat:1.1.0'
    
        //Testing
        testImplementation 'junit:junit:4.12'
        androidTestImplementation 'androidx.test:rules:1.2.0'
        androidTestImplementation 'androidx.test.ext:junit:1.1.1'
        androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
        androidTestImplementation('com.android.support.test.espresso:espresso-contrib:3.0.2'){
            exclude group: 'com.android.support', module: 'appcompat'
            exclude module: 'recyclerview-v7'
            exclude module: 'appcompat-v7'
        }
    

    【讨论】:

      猜你喜欢
      • 2018-04-25
      • 2019-04-09
      • 2015-12-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-05
      相关资源
      最近更新 更多