0

I have just installed Android Studio 3.0.1 and I have attempted numerous solutions from the previous time this question was asked but none of them seem to be working. I still receive this error: Failed to resolve: com.android.support:appcompat-v7:26.1.0

My top level build file is as follows:

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

    allprojects{
        repositories{
            jcenter()
        }
    }
    repositories {
        // Gradle 4.1 and higher include support for Google's Maven repo using
        // the google() method. And you need to include this repo to download
        // Android plugin 3.0.0 or higher.
        maven { url "https://maven.google.com" }
        google()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
    }
}

My app build.gradle file includes:

apply plugin: 'com.android.application'

repositories {
    maven { url "https://maven.google.com" }
    jcenter { url "http://jcenter.bintray.com/" }
}

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.1"

    defaultConfig {
        applicationId "com.example.application"
        minSdkVersion 15
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
    }
    buildTypes {

        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:26.0.1'
    compile 'com.android.support:design:23.1.1'
}
InsaneCat
  • 2,115
  • 5
  • 21
  • 40
Anatoly
  • 3,266
  • 4
  • 17
  • 28
  • 1
    Possible duplicate of [Could not resolve com.android.support:appcompat-v7:26.1.0 in Android Studio new project](https://stackoverflow.com/questions/47448502/could-not-resolve-com-android-supportappcompat-v726-1-0-in-android-studio-new) – InsaneCat Dec 09 '17 at 12:20

3 Answers3

1

Make your 'com.android.support:design:23.1.1' - same version as your appcompat-v7. Then remove from app gradle

repositories { maven { url "https://maven.google.com" } jcenter { url "http://jcenter.bintray.com/" } }

Yupi
  • 4,402
  • 3
  • 18
  • 37
  • Great. Just make sure in future you check which gradle you are implementing stuffs. – Yupi Dec 09 '17 at 13:04
1

You project build.gradle should be similar to this

buildscript {
    repositories {
        google()
        jcenter()
        mavenCentral()
    }
    dependencies {
        classpath "com.android.tools.build:gradle:3.0.1"
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        mavenCentral()
    }
}

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

And you should use the same version for your libraries like this:

implementation "com.android.support:appcompat-v7:26.0.1"
implementation "com.android.support:design:26.0.1"
MatPag
  • 41,742
  • 14
  • 105
  • 114
  • Thanks. Now I receive this message: Unable to resolve dependency for ':p0031firstproject@debugAndroidTest/compileClasspath': Could not download javawriter.jar (com.squareup:javawriter:2.1.1) (p0031firstproject - is the name of my project) – Anatoly Dec 09 '17 at 12:37
  • You don't have any dependency in the app `build.gradle` which refers to `com.squareup:javawriter` Are you sure you posted the complete file? – MatPag Dec 09 '17 at 12:40
  • BTW I've added `mavenCentral()` to my answer, copy them at the same position and check if it works now – MatPag Dec 09 '17 at 12:43
0

The man cause of the issue is the below code.

allprojects{ repositories{ jcenter() } }

Replace it with this one

allprojects { repositories { google() jcenter() } }

Please let me know if it solves your problem.

Alok
  • 881
  • 1
  • 11
  • 18