59

Since I have upgraded my Nexus 5x to Android O DP3 I am not able to test my applications. I get the error for not having configured my Gradle-file to work with the new API-level (26).

So I changed this and the dependencies, but I keep getting errors on ALL my support libraries like

Failed to resolve: com.android.support:design:26.0.0-beta2

Clicking on

Install repository and sync project

Pops up a progressdialog for downloading the right dependency but does not remove the error. Cleaning up project, installing repositories and then rebuilding the project won't work either.

appcompat-v7

On appcompat-v7:26.0.0-beta2 I get (before even a Gradle sync) squickly lines with the error:

When using a compileSdkVersion older than android-O revision 2,
the support library version must be 26.0.0-alpha1 or lower (was 26.0.0-beta2)

Can someone help me get the gradle file to be configured correctly for Android API 26? Any help would be appreciated.

PS: I'm using Gradle 3.0.0-alpha3 at the moment but get the same error on Gradle 2.3.2

My Gradle file:

apply plugin: 'com.android.application'

android {
compileSdkVersion 26
buildToolsVersion '26.0.0'

defaultConfig {
    applicationId "********"
    minSdkVersion 21
    targetSdkVersion 26
    versionCode 3
    versionName "2.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:26.0.0-beta2'
compile 'com.android.support:design:26.0.0-beta2'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.android.support:cardview-v7:26.0.0-beta2'
compile 'com.android.support:recyclerview-v7:26.0.0-beta2'
compile 'com.redbooth:WelcomeCoordinator:1.0.1'
compile 'com.github.kittinunf.fuel:fuel-android:1.4.0'
compile 'com.pkmmte.view:circularimageview:1.1'
compile 'com.ramotion.foldingcell:folding-cell:1.1.0'
}
Community
  • 1
  • 1
GunnarK
  • 730
  • 1
  • 5
  • 11

6 Answers6

131

Have you added the google maven endpoint?

Important: The support libraries are now available through Google's Maven repository. You do not need to download the support repository from the SDK Manager. For more information, see Support Library Setup.

Add the endpoint to your build.gradle file:

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

Which can be replaced by the shortcut google() since Android Gradle v3:

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

If you already have any maven url inside repositories, you can add the reference after them, i.e.:

allprojects {
    repositories {
        jcenter()
        maven {
            url 'https://jitpack.io'
        }
        maven {
            url 'https://maven.google.com'
        }
    }
}
I.G. Pascual
  • 5,818
  • 5
  • 42
  • 58
  • 1
    Your code is wrong, jcenter() is *before* maven tag – greywolf82 Jun 13 '17 at 06:37
  • Thanks! This worked for me. The specified url was jitpack.io – GunnarK Jun 13 '17 at 12:13
  • 1
    The error "When using a compileSdkVersion older than android-O revision 2, the support library version must be 26.0.0-alpha1 or lower (was 26.0.0-beta2)" Is still showing. But I'm able to build and run the app on my phone without problems, it seems.. Any thoughts? – GunnarK Jun 13 '17 at 12:18
  • @GunnarK you can add both urls placing them one after another, just like this: `maven { url 'https://maven.google.com' } maven { url 'https://jitpack.io' }` – I.G. Pascual Jun 13 '17 at 14:51
  • @GunnarK I guess your Android Studio has not updated the latest sdk available (which right now is eventually 26.0.0-beta2). Maybe the update urls are cached due to a proxy or sth. If you go to _Settings > Appearance & Behavior > System Settings > Android SDK_ you have three tabs. The last one `SDK Update Sites` check _Force https://... resources [...]_ try restarting – I.G. Pascual Jun 13 '17 at 15:12
  • @I.G.Pascual Thank you for this clarification. I have set the maven repository to `repositories { jcenter() maven { url 'https://jitpack.io' } maven { url 'https://maven.google.com' } }` The red underline error on appcompat-v7 seems to only show itself in Android Studio 3.0 Canary. Checking Forced updates and restarting didn't do anything.. In AS 2.3.2 the error is not showing. Probably a bug in Canary, since the building process for an app functions normally – GunnarK Jun 14 '17 at 13:33
  • 1
    @GunnarK I've installed AS 3.0, same happening here. I guess sth's missing in the version tables/xml... we won't worry about it – I.G. Pascual Jun 14 '17 at 18:23
  • No fix on *When using a compileSdkVersion older than android-O revision 2, the support library version must be 26.0.0-alpha1 or lower (was 26.0.0-beta2)* – nyconing Jun 15 '17 at 06:10
  • is adding google() on repositories section is same as above? – Banee Ishaque K Jul 12 '17 at 14:05
  • @BaneeIshaqueK yes it is, but only since Android Gradle plugin v 3.0.0-alpha1 in Android Studio 3. I'd recomend waiting until Gradle plugin is in more stable mood :) – I.G. Pascual Jul 13 '17 at 09:07
  • 2
    upgraded to alpha7, but layout designer is not working on alpha7 (already filed a bug, see it here [Layout Designer Not Working...](https://issuetracker.google.com/issues/63943042). Now, i downgraded to latest stable version, 2.3.3. is `google()` will work? i am using global gradle distribution, and my version is : 4.1-milestone-1. And what about `com.android.tools.build:gradle:3.0.0-alpha7` line in `build.gradle` file? – Banee Ishaque K Jul 23 '17 at 09:20
  • You are a legend! Thank you so much! – Andrei Cusnir May 19 '19 at 16:32
14
allprojects {
    repositories {
        jcenter()
        maven {
            url "https://maven.google.com"
        }
    }
}

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.1"
    defaultConfig {
        applicationId "com.keshav.retroft2arrayinsidearrayexamplekeshav"
        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'
        }
    }
}
 compile 'com.android.support:appcompat-v7:26.0.1'
    compile 'com.android.support:recyclerview-v7:26.0.1'
    compile 'com.android.support:cardview-v7:26.0.1'
Keshav Gera
  • 10,807
  • 1
  • 75
  • 53
8

Appart from setting maven source url to your gradle, I would suggest to add both design and appcompat libraries. Currently the latest version is 26.1.0

maven {
    url "https://maven.google.com"
}

...

compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.support:design:26.1.0'
Ch Vas
  • 993
  • 8
  • 10
7

You could add google() to repositories block

allprojects {
    repositories {
        jcenter()
        maven {
            url 'https://github.com/uPhyca/stetho-realm/raw/master/maven-repo'

        }
        maven {
            url "https://jitpack.io"
        }
        google()
    }
}
toidv
  • 842
  • 2
  • 9
  • 19
  • 3
    Only since [Android Gradle plugin v 3.0.0-alpha1](https://stackoverflow.com/questions/44691858/failed-to-resolve-com-android-support-design25-4-0#comment76668403_44691903), in Android Studio 3 – I.G. Pascual Jul 13 '17 at 09:08
6

Appears to be resolved by Android Studio 3.0 Canary 4 and Gradle 3.0.0-alpha4.

jrisch
  • 132
  • 1
  • 9
5

you must add in your MODULE-LEVEL build.gradle file with:

//module-level build.gradle file
repositories {
    maven {
        url 'https://maven.google.com'

    }
}

see: Google's Maven repository

I have observed that when I use Android Studio 2.3.3 I MUST add repositories{maven{url 'https://maven.google.com'}} in MODULE-LEVEL build.gradle. In the case of Android Studio 3.0.0 there is no need for the addition in module-level build.gradle. It is enough the addition in project-level build.gradle which has been referred to in the other posts here, namely:

//project-level build.gradle file
allprojects {
 repositories {
    jcenter()
    maven {
        url 'https://maven.google.com/'
        name 'Google'
    }
  }
}

UPDATE 11-14-2017: The solution, that I present, was valid when I did the post. Since then, there have been various updates (even with respect to the site I refer to), and I do not know if now is valid. For one month I did my work depending on the solution above, until I upgraded to Android Studio 3.0.0

billst
  • 649
  • 1
  • 8
  • 14
  • What error did you see that prompted you to add the additional configuration at the module-level? – jk7 Oct 13 '17 at 18:46
  • @jk7: As a example, I present the errors for some libraries: Failed to resolve: com.android.support:support-v4:26.1.0, Failed to resolve: com.android.support.test.espresso:espresso-core:3.0.1, Failed to resolve: com.android.support:appcompat-v7:26.1.0 etc – billst Oct 22 '17 at 18:32
  • @billst Did you check you using the same versions and maintain consistency? – Rohan Oct 25 '17 at 21:13