I have an android module with this build.gradle file:
apply plugin: 'com.android.library'
android {
        compileSdkVersion 27
        defaultConfig {
                minSdkVersion 14
                targetSdkVersion 27
                versionCode 1
                versionName "1.0.0"
        }
}
dependencies {
        implementation 'com.android.support:support-compat:27.1.1'
}
And received this error during Gradle sync process:
Failed to resolve: support-compat
The dependency identifier that I used is exactly according to https://developer.android.com/topic/libraries/support-library/packages#v4-compat (when I write this question).
The interesting note is the problem is only for version 27.1.1! All other versions that I tested (24.2.0, 26.0.0, 27.0.0 and even 27.1.0) are OK.
Also, All other support libraries that I tested from this version (27.1.1) are OK. Here a list of them:
implementation 'com.android.support:appcompat-v7:27.1.1' 
implementation 'com.android.support:gridlayout-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:support-v4:27.1.1' 
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation 'com.android.support:support-annotations:27.1.1'
Screanshot:

There is no difference if I insert the dependency in app module or library module.
My project-level build.gradle file:
buildscript {
    repositories {
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.3'
    }
}
allprojects {
    repositories {
        jcenter()
        google()
    }
}
My gradle-wrapper.properties file:
#Wed Jul 18 14:24:51 IRDT 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
The google() repository needs to be listed before the jcenter() repository. I can reproduce the issue by swapping their order under allprojects.
Check whether you included this in the repositories section of app gradle file.
allprojects {
    repositories {
        jcenter()
        maven {
            url "https://maven.google.com"
        }
    }
}
Try as follow:
buildscript {
    ...
}
allprojects {
    repositories {
        google()
        //use maven repo
        mavenCentral()
        maven {
            url 'https://jitpack.io'
        }
        jcenter()
    }
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With