Failed to resolve: support-compat ONLY FOR :27.1.1
Asked Answered
B

3

7

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:

enter image description here

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
Burkhart answered 18/7, 2018 at 11:55 Comment(0)
A
6

Check whether you included this in the repositories section of app gradle file.

allprojects {
    repositories {
        jcenter()
        maven {
            url "https://maven.google.com"
        }
    }
}
Auricle answered 18/7, 2018 at 12:4 Comment(1)
I don't know what happened! replacing both google() with maven { url "https://maven.google.com" } solved the problem. Now replacing it to back makes no issue!!! Thanks anyway.Burkhart
L
7

The google() repository needs to be listed before the jcenter() repository. I can reproduce the issue by swapping their order under allprojects.

Lick answered 18/12, 2018 at 20:43 Comment(0)
A
6

Check whether you included this in the repositories section of app gradle file.

allprojects {
    repositories {
        jcenter()
        maven {
            url "https://maven.google.com"
        }
    }
}
Auricle answered 18/7, 2018 at 12:4 Comment(1)
I don't know what happened! replacing both google() with maven { url "https://maven.google.com" } solved the problem. Now replacing it to back makes no issue!!! Thanks anyway.Burkhart
R
2

Try as follow:

buildscript {
    ...
}

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

        jcenter()
    }
}
Radiology answered 18/7, 2018 at 12:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.