Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Failed to resolve: support-compat ONLY FOR :27.1.1

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
like image 697
Mir-Ismaili Avatar asked Jul 18 '18 11:07

Mir-Ismaili


3 Answers

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

like image 195
Jarett Millard Avatar answered Oct 16 '22 19:10

Jarett Millard


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

allprojects {
    repositories {
        jcenter()
        maven {
            url "https://maven.google.com"
        }
    }
}
like image 28
Kakumanu siva krishna Avatar answered Oct 16 '22 21:10

Kakumanu siva krishna


Try as follow:

buildscript {
    ...
}

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

        jcenter()
    }
}
like image 2
Abner Escócio Avatar answered Oct 16 '22 19:10

Abner Escócio