Mehran
Mehran

Reputation: 501

compile project dependencies with latest version of android support library

I was using 25 as targetSdkVersion,compileSdkVersion in my project. Then a warning showed up.

Not targeting the latest versions of Android; compatibility modes apply. Consider testing and updating this version. Consult the android.os.Build.VERSION_CODES javadoc for details.

So I raised it to 26. And I opened my SDK Manager and updated everything:

SDK Tools , SDK Platform-Tools , etc.

Then another warning showed up:

This support library should not use a lower version (25) than the targetSdkVersion (26)

I was using this version:

    compile 'com.android.support:appcompat-v7:25.3.1'

Now I don't know to which version exactly should I change to.

I tried 7:26.0.0 which my SDK Platform-Tools version is now.

I tried 7:26.0.2 which my SDK Tools version is now.

Both of them give me error after sync:

Failed to resolve: com.android.support.appcompat-v7:26.0.2

Install repository and sync project

Then if I click on Install nothing will happen

Now I have a simple question. How can I find out what is the latest version of support library?

Upvotes: 11

Views: 5647

Answers (4)

IAmNotARobot
IAmNotARobot

Reputation: 1445

This works for me. Try this in your build.gradle

buildscript {
repositories {
    jcenter()
}

dependencies {
    classpath 'com.android.tools.build:gradle:2.3.3'
    classpath 'com.google.gms:google-services:3.0.0'
}
}

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

Upvotes: 0

Suragch
Suragch

Reputation: 511566

In Android Studio beta4 I had to add google() to the repositories in the projects build.gradle file. This seems to be an update from Celt K. B.'s answer.

This is what my build.gradle file looks like now.

buildscript {

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0-beta4'


        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

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

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

A trick is to create a new project and see what the settings are in the default build.gradle files.

Upvotes: 0

Celt K. B.
Celt K. B.

Reputation: 789

Add maven repository to your project gradle file:

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

Upvotes: 27

Marcin Orlowski
Marcin Orlowski

Reputation: 75619

Then another warning showed up:

This support library should not use a lower version (25) than the targetSdkVersion (26)

Now I don't know to wich version exactly should I change to.

Either one as you simply should have version match here, so either lower your targetSdkVersion to 25 or use valid version for 26+ libs.

Error:(29, 13) Failed to resolve: com.android.support:cardview-v7:26.0.0 Install Repository and sync project

26 is not officially out yet so just RCs or betas, therefore valid version string is i.e. 26.0.0-beta1.

Finally, you should check if your repository includes new google maven repo, otherwise some artefacts will not be available for your project incl. recent betas of support libs.

See docs for details of setting it all up.

Upvotes: 8

Related Questions