Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio Gradle Project Sync - Failed To Resolve Espresso-Core and Appcompat

I am following the 'First App' tutorial found at https://developer.android.com/training/basics/firstapp/index.html. However, on creating a default 'Empty activity' project and trying to build it, I receive the following errors:

  • Error:(23, 24) Failed to resolve: com.android.support.test:espresso-core:2.2.2
  • Error:(26, 13) Failed to resolve: com.android.support:appcompat-v7:26.+

My (default / autogenerated) build.gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.0"
    defaultConfig {
        applicationId "com.example.myfirstapp"
        minSdkVersion 15
        targetSdkVersion 26
        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 fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:26.+'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    testCompile 'junit:junit:4.12'
}

Although I have looked at several related Stack Overflow questions, I am yet to find a solution that works. I am using a fresh, default install of Android Studio 2.3.3.

like image 882
Oliver Wales Avatar asked Mar 08 '23 21:03

Oliver Wales


2 Answers

You should check if your repository includes new google maven repo.
Something like:

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

See docs for details.

like image 112
Gabriele Mariotti Avatar answered Apr 07 '23 06:04

Gabriele Mariotti


Used compile 'com.android.support:appcompat-v7:26.0.0-alpha1'

like image 36
jojemapa Avatar answered Apr 07 '23 08:04

jojemapa