首页 > 解决方案 > 无法使用 TypeSafeMatcher

问题描述

我正在尝试从此处创建扩展 TypeSafeMatcher 的 ToastMatcher 类,但由于某种原因,上下文操作和手动添加到 gradle 都失败了。给出的上下文操作选项如下: 但选择任一添加库选项都不会改变。所有使用 import 语句的尝试都是徒劳的。这是我的 gradle 依赖项:在此处输入图像描述

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.3.1'
    implementation 'com.google.android.material:material:1.4.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.0'
    implementation 'androidx.navigation:navigation-fragment:2.3.5'
    implementation 'androidx.navigation:navigation-ui:2.3.5'
    implementation 'com.jjoe64:graphview:4.2.2'
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'

    implementation "com.hootsuite.android:nachos:1.1.1"
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
    androidTestImplementation 'androidx.test:runner:1.4.0'
    androidTestImplementation 'androidx.test:rules:1.4.0'
    implementation "androidx.coordinatorlayout:coordinatorlayout:1.1.0"
    testImplementation 'io.rest-assured:rest-assured:4.4.0'
    testImplementation 'org.hamcrest:hamcrest:2.2'
    implementation 'com.android.volley:volley:1.2.1'
    implementation "android.arch.lifecycle:extensions:1.1.1"
    annotationProcessor "android.arch.lifecycle:compiler:1.1.1"

    testImplementation 'com.google.guava:guava:18.0'
    testImplementation 'com.squareup.spoon:spoon-client:1.1.1'
    testImplementation('com.jakewharton.espresso:espresso:1.1-r3')
}

这是我在 Android Studio 中出现的整个课程: 在此处输入图像描述 希望有人知道如何解决这个问题,因为我非常坚持:/

标签: androidandroid-studioandroid-gradle-pluginhamcrest

解决方案


推荐阅读