Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't resolve symbol 'ActivityTestRule'

I'm learn to use espresso to test my app, but ActivityTestRule always can't be resolved. Here is my app/build.gradle config, and I'm sure that I put test classes at src/androidTest.

Many thanks for help!!

enter image description here

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    buildToolsVersion "25.0.2"
    defaultConfig {
        applicationId "com.example.android.teatime"
        minSdkVersion 16
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile 'com.android.support:design:27.1.1'
    compile 'com.android.support:support-annotations:27.1.1'
    compile 'com.google.android.gms:play-services-appindexing:9.8.0'
    // Testing-only dependencies
    androidTestCompile 'com.android.support:support-annotations:27.1.1'
    androidTestCompile 'com.android.support.test.espresso:espresso-core:3.0.2'
    androidTestCompile 'com.android.support.test:runner:1.0.2'
    androidTestCompile 'com.android.support.test.espresso:espresso-contrib:3.0.2'
    androidTestCompile 'com.android.support.test:rules:1.0.2'
}
like image 967
CarsonJc Avatar asked May 30 '18 03:05

CarsonJc


1 Answers

I hope this will work for you.

Use

androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'

Instead

androidTestCompile 'com.android.support.test.espresso:espresso-core:3.0.2'
androidTestCompile 'com.android.support.test:runner:1.0.2'
like image 200
GParekar Avatar answered Nov 08 '22 04:11

GParekar