5

I'm going to build a project. When I create the project, I encounter the following error

ERROR: Failed to resolve: espresso-core
Affected Modules: mvp-app


ERROR: Failed to resolve: runner
Affected Modules: mvp-app

and my build.gradle(module) file

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "ir.sabmanage.mvp"
        minSdkVersion 16
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.android.support:design:28.0.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

    implementation 'com.android.support:exifinterface:28.0.0'
    implementation 'com.ss.bottomnavigation:bottomnavigation:1.5.2'
    implementation 'com.squareup.retrofit2:retrofit:2.4.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.1.0'
    implementation 'com.squareup.okhttp3:okhttp:3.10.0'
    implementation 'com.squareup.picasso:picasso:2.71828'
    implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
    implementation 'io.reactivex.rxjava2:rxjava:2.1.14'
    implementation 'com.squareup.retrofit2:adapter-rxjava2:2.4.0'
}

and my build.gradle(project) file

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        google()
        jcenter()
        mavenCentral()

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.4.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

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

    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

How to fix this error? Has anyone faced this problem? I found a solution but it did not answer me android studio failed to resolve: runner and failed to resolve: espresso-core and failed to resolve: monitor

abolfazl bazghandi
  • 935
  • 15
  • 29

2 Answers2

3

If you are using androidx dependencies you may want to replace the following implementations:

androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

with these:

androidTestImplementation 'androidx.test:runner:1.3.0-alpha03'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0-alpha03'
Parham
  • 116
  • 10
0

espresso 3.1.0 is the latest available version. Also you don't need to mavencentral repo. for details on build.gradle refer to sample code.

https://developer.android.com/training/testing/espresso/setup

Ranjan Kumar
  • 1,164
  • 7
  • 12
  • hi androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.2.0' **This item does not exist** and get error `ERROR: Failed to resolve: com.android.support.test.espresso:espresso-core:3.2.0'` – abolfazl bazghandi Jun 03 '19 at 20:48