0

I'm trying to upgrade my android support libraries to the latest versions, eg.

dependencies {
    ...
    compile 'com.android.support:design:26.0.0'
}

However, when I run the gradle sync, these libraries cannot be resolved:

Error:(30, 13) Failed to resolve: com.android.support:design:26.0.0
Install Repository and sync project
Show in File
Show in Project Structure dialog

Clicking "Install Repository and sync project" does nothing.

This SO answer suggests it might be due to not having the google() repository in my build.gradle. However, if I add it and try to sync, I get "Gradle DSL method not found: 'google()'. It lists possible causes:

  1. The project 'xyz' may be using a version of the Android Gradle plug-in that does not contain the method (e.g. 'testCompile' was added in 1.1.0). Upgrade plugin to version 2.3.3 and sync project <= I am using "classpath 'com.android.tools.build:gradle:2.3.3'"
  2. The project 'xyz' may be using a version of Gradle that does not contain the method. Open Gradle wrapper file. <= using gradle 3.3
  3. The build file may be missing a Gradle plugin. Apply Gradle plugin. <= Again, the gradle plugin is listed in the dependencies of the build file.

How can I upgrade to the latest Android support libraries?

tytk
  • 2,082
  • 3
  • 27
  • 39

1 Answers1

1

Make sure that you follow the instructions here regarding how to set up your support libraries. (Works for Android Studio 2.3.3)

Adding Support Libraries

In order to use a Support Library, you must modify your application's project's classpath dependencies within your development environment. You must perform this procedure for each Support Library you want to use.

To add a Support Library to your application project:

  1. Open the build.gradle file for your application.

  2. Make sure that the repositories section includes a maven section with the "https://maven.google.com" endpoint. For example:

    allprojects {
        repositories {
            jcenter()
            maven {
                url "https://maven.google.com"
            }
        }
    }
  1. Add the support library to the dependencies section. For example, to add the v4 core-utils library, add the following lines:
     dependencies {
              ...
              compile "com.android.support:support-core-utils:26.0.0"
          }
Cheticamp
  • 61,413
  • 10
  • 78
  • 131
  • Thanks for the link. I tried following these instructions. The project compiles successfully with the additional repository added, so I think that issue is fixed. But when I upgrade my dependency versions I now get some random "Error:(15, 21) No resource found that matches the given name: attr 'android:keyboardNavigationCluster'." in xyz/app/build/intermediates/res/merged/debug/values-v26/values-v26.xml. This is Android Studio 2.3.3. – tytk Aug 07 '17 at 23:56
  • @tytk Try cleaning and rebuilding the project. That may take care of the problem. Glad the linked instructions worked for you. – Cheticamp Aug 08 '17 at 00:09
  • Updated dependency versions, ran `./gradlew clean`, then synced the project. Got the same error unfortunately. – tytk Aug 08 '17 at 00:12
  • @tytk That one is a mystery to me. You may want to consider posting a new question. – Cheticamp Aug 08 '17 at 00:15
  • @tytk You need compileSdkVersion 26, too – laalto Aug 23 '17 at 19:29