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.gradle
file 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?
Best Answer
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.
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.
gradle-wrapper.properties sample:
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.