无法解析符号‘;ActivityTestRule’;关于androidx

无法解析符号‘;ActivityTestRule’;关于androidx,android,junit4,android-testing,androidx-test,Android,Junit4,Android Testing,Androidx Test,我正在尝试测试我的活动,但无法导入ActivityTestRule 我的gradle文件 apply plugin: 'com.android.application' apply plugin: 'com.google.gms.google-services' // Add the Firebase Crashlytics plugin. apply plugin: 'com.google.firebase.crashlytics' android { compileSdkVersio

我正在尝试测试我的活动,但无法导入ActivityTestRule

我的gradle文件

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
// Add the Firebase Crashlytics plugin.
apply plugin: 'com.google.firebase.crashlytics'
android {
    compileSdkVersion 30
    defaultConfig {
        applicationId "com.example”
        minSdkVersion 23
        targetSdkVersion 30
        versionCode 3
        versionName "1.3"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/INDEX.LIST'
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
        debug {
            testCoverageEnabled true
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    testOptions {
        unitTests.returnDefaultValues = true
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.3'
    testImplementation 'junit:junit:4.13.1'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    implementation 'com.google.android.material:material:1.2.1'
    androidTestImplementation 'org.junit.jupiter:junit-jupiter:5.7.0'
    testImplementation 'org.objenesis:objenesis:2.6'
    // Espresso Core library
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
// AndroidJUnitRunner and JUnit Rules
    androidTestImplementation 'androidx.test:runner:1.3.0'
    androidTestImplementation 'androidx.test:rules:1.3.0'
    // Optional -- UI testing with UI Automator
    androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.2.0'
    
}
编辑 我也尝试过ActivityScenarioRule。同样的问题,无法解决符号ActivityScenarioRule

public ActivityScenarioRule rule = new ActivityScenarioRule<>(LoginActivity.class);
public ActivityScenarioRule=new ActivityScenarioRule(LoginActivity.class);