3

I am getting this error during gradle build in android studio. And I am unable to figure out what I am missing.

Error:Could not find com.android.tools.build:gradle:2.3.3. Searched in the following locations: file:/C:/Program Files/Android/Android Studio/gradle/m2repository/com/android/tools/build/gradle/2.3.3/gradle-2.3.3.pom
file:/C:/Program Files/Android/Android Studio/gradle/m2repository/com/android/tools/build/gradle/2.3.3/gradle-2.3.3.jar
https://maven.google.com/com/android/tools/build/gradle/2.3.3/gradle-2.3.3.pom
https://maven.google.com/com/android/tools/build/gradle/2.3.3/gradle-2.3.3.jar

Here is my build.gradlefile configuration

`
all sub-projects/modules.
    allprojects {
        repositories {
            jcenter()
            maven {
                url "https://maven.google.com"
            }
            maven {
                url 'https://jitpack.io'
            }
        }
    }

    buildscript {
        dependencies {
            classpath 'com.android.tools.build:gradle:2.3.3'
        }
        repositories {
            maven {
                url 'https://maven.google.com/'
                name 'Google'
            }
        }
    }

    ext {
        supportlib_version = '26.0.2'
        gps_version = '11.2.0'
    }

    //Ensure that all dependencies use the same version of the Android Support library
    subprojects {
        project.configurations.all {
            resolutionStrategy.eachDependency { details ->
                if (details.requested.group == 'com.android.support'
                        && !details.requested.name.contains('multidex')) {
                    details.useVersion "$supportlib_version"
                }
                if (details.requested.group == 'com.google.android.gms'
                        && !details.requested.name.contains('multidex')) {
                    details.useVersion "$gps_version"
                }
            }
        }
    }

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

Could you help me what am I missing?

Abhishek Raj
  • 107
  • 1
  • 3
  • 10

3 Answers3

7

Add jcenter() to buildscript repositories if you are using gradle plugin 2.x.


Here's a copy of build.gradle(Project) from my old project.

buildscript {
    repositories {
        // for 2.x
        jcenter()
    }
    dependencies {
        // classpath 'com.android.tools.build:gradle:2.2.0'
        classpath 'com.android.tools.build:gradle:2.3.3'

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

allprojects {
    repositories {
        jcenter()
    }
}

If your gradle (the one distributed by Gradle) version is low,
also need to edit gradle-wrapper.properties.

Minimum version of Gradle is 3.3 for plugin 2.3.3.

Plugin version 2.3.0+ :
Required Gradle version 3.3+

gradle-wrapper.properties sample:

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
#distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip

Please see Update Gradle. Available versions are listed in this page.


For information:

This exists (jcenter).
https://bintray.com/android/android-tools/com.android.tools.build.gradle/2.3.3

This does not exist (Google's Maven repository). It's from 3.0, I think.
https://maven.google.com/com/android/tools/build/gradle/2.3.3/gradle-2.3.3.pom

This exists
https://maven.google.com/com/android/tools/build/gradle/3.0.0/gradle-3.0.0.pom


For Gradle version >= 3.0.0

Please see Update the Android Plugin for Gradle and Update Gradle.

Toris
  • 2,348
  • 13
  • 16
  • I have added jcenter(). Still its giving me following error. `Error:Could not find com.android.tools.build:gradle:2.3.3. Searched in the following locations: file:/C:/Program Files/Android/Android Studio/gradle/m2repository/com/android/tools/build/gradle/2.3.3/gradle-2.3.3.jar https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/2.3.3/gradle-2.3.3.pom https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/2.3.3/gradle-2.3.3.jar` – Abhishek Raj Nov 15 '17 at 19:52
  • Seems accessing Google's maven repo. How about commenting out `maven { url 'https://maven.google.com/' name 'Google' }` in buildscript repositories? – Toris Nov 15 '17 at 19:56
  • I have only this in build script `buildscript { dependencies { classpath 'com.android.tools.build:gradle:2.3.3' } repositories { google() } }` – Abhishek Raj Nov 15 '17 at 20:15
  • Worked for me. Thanks – vyi May 19 '18 at 15:45
  • As a newbie, `Minimum version of Gradle is 3.3 for plugin 2.3.3.` helped me. I had thought those were the same thing that should match versions. – Hiro Dec 14 '20 at 16:07
5

You need to use the right version of the gradle and gradle plugin

If you are using plugin 2.2.3 you should use gradle 2.14.1+. If you updated your Android Studio, you should use plugin version 3.0.0+ with gradle 4.1+.

Please, take a lok at documentation:
https://developer.android.com/studio/releases/gradle-plugin.html

Gradle plugin: build.gradle project file
Gradle: gradle-wrapper.properties file

Maicon Hellmann
  • 450
  • 3
  • 13
0

i hit the similar issue recently after upgrading Android Studio to 3.0. You might want to do some cleanup (erasing .gradle and .idea folders) and rebuild, as discussed in Android studio build error after update to v 3.0.

Chun-Yen Wang
  • 568
  • 2
  • 10