Why am I getting "could not find com.android.tools.build:gradle" error?

committedandroider picture committedandroider · Jun 21, 2015 · Viewed 34.5k times · Source

This is based off my last question as well.

Following this tutorial, I cloned the project into my machine and am trying to get the project to build properly.

In the process of fixing the error I got in my last question, I encountered a new error.
This is the section of the build script I am trying to fix/edit

buildscript {
     repositories {
         mavenCentral()
         mavenLocal()
         maven { url 'https://github.com/steffenschaefer/gwt-gradle-plugin/raw/maven-repo/' }
      }
      dependencies {
            classpath 'de.richsource.gradle.plugins:gwt-gradle-plugin:0.3'
            classpath 'com.android.tools.build:gradle:1.2.3'
      }
 }

Following the instructions on how to check Gradle version, I checked mine and saw that I was running Gradle version 2.2.1. Based off that, I changed

    classpath 'com.android.tools.build:gradle:1.2.3'

to

   classpath 'com.android.tools.build:gradle:2.2.1'

However after changing that build script code, and attempting to rebuild my project, I get the above mentioned error(full stack trace below)

    Error:Could not find com.android.tools.build:gradle:2.2.1.
Searched in the following locations:
    file:/C:/Program Files/Android/Android Studio/gradle/m2repository/com/android/tools/build/gradle/2.2.1/gradle-2.2.1.pom
    file:/C:/Program Files/Android/Android Studio/gradle/m2repository/com/android/tools/build/gradle/2.2.1/gradle-2.2.1.jar
    https://repo1.maven.org/maven2/com/android/tools/build/gradle/2.2.1/gradle-2.2.1.pom
    https://repo1.maven.org/maven2/com/android/tools/build/gradle/2.2.1/gradle-2.2.1.jar
    file:/C:/Users/chris/.m2/repository/com/android/tools/build/gradle/2.2.1/gradle-2.2.1.pom
    file:/C:/Users/chris/.m2/repository/com/android/tools/build/gradle/2.2.1/gradle-2.2.1.jar
    https://github.com/steffenschaefer/gwt-gradle-plugin/raw/maven-repo/com/android/tools/build/gradle/2.2.1/gradle-2.2.1.pom
    https://github.com/steffenschaefer/gwt-gradle-plugin/raw/maven-repo/com/android/tools/build/gradle/2.2.1/gradle-2.2.1.jar
Required by:
    :theplanethatcouldntflygood:unspecified

Does anyone know why I am getting this error or how to fix this? It doesn't make sense for me to point the Java compiler(classpath) at a Gradle Version that I am not even using.

Answer

n4h0y picture n4h0y · Jun 21, 2015

You are confusing between android gradle plugin and gradle version.

This classpath 'com.android.tools.build:gradle:1.2.3' is a gradle plugin for Android and as of this time, 1.2.3 is the latest.

The gradle version itself is in gradle-wrapper.properties file. 2.4 is the latest version,