udacity / AdvancedAndroid_TeaTime

115 stars 307 forks source link

AndroidJUnit4 and ActivityTestRule are not recognized #28

Open jonny123d opened 4 years ago

jonny123d commented 4 years ago

I'm trying to do the first exercise. I added maven repository in the build.gradle of the project, without this I can't compile the project:

allprojects {
    repositories {
        maven {
            url 'https://maven.google.com'
        }
        jcenter()
    }
}

Then I added the dependecies in the build.gradle of the app:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    defaultConfig {
        applicationId "com.example.android.teatime"
        minSdkVersion 16
        targetSdkVersion 25
        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:25.1.0'
    compile 'com.android.support:support-annotations:25.1.0'
    compile 'com.google.android.gms:play-services-appindexing:9.8.0'

    // DONE (4) Add the required Espresso UI Testing dependencies
    // Testing-only dependencies
    androidTestCompile 'com.android.support:support-annotations:25.1.0'
    androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
}

But AndroidJUnit4 and ActivityTestRule are not recognized and I can't import them.

My Android Studio: Android Studio 4.0 Build #AI-193.6911.18.40.6514223, built on May 20, 2020 Runtime version: 1.8.0_242-release-1644-b01 amd64 VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o Windows 10 10.0 GC: ParNew, ConcurrentMarkSweep Memory: 1237M Cores: 8 Registry: ide.new.welcome.screen.force=true Non-Bundled Plugins: com.microsoft.vso.idea, org.intellij.plugins.markdown