Gradle fails to resolve the buildscript classpath, so the build never starts
Could not resolve all dependencies for configuration ':classpath'.Short answer
Gradle could not download a build plugin, usually the Android Gradle plugin. The cause is nearly always one of three: google() is missing from the plugin repositories, a proxy or offline mode blocks the download, or a bad cached result is being reused. The error lines under it name the failing artifact.
Fix it fast
1Find out which cause you have
Run the build with a stack trace and read the first 'Could not' line under the error. It names the artifact and the repository Gradle tried.
./gradlew help --stacktrace2Match what you see, then jump to its fix
- 1
Could not find com.android.tools.build:gradle (and the list of searched locations has no dl.google.com)google() is not in the repositories that Gradle searches for pluginsFix - 2
Could not GET ... Connect to ... failed or Read timed out, on a network with a proxyA proxy or firewall blocks Gradle's downloadFix - 3
Offline mode is switched on in the IDE or the build runs with --offlineOffline mode is on, or the cache holds a failed resultFix
- 1
What does the error look like?
Could not resolve all dependencies for configuration ':classpath'.Could not find com.android.tools.build:gradle:8.x.x.Could not GET 'https://dl.google.com/dl/android/maven2/...'
Cause 1 of 3
google() is not in the repositories that Gradle searches for plugins
1Check
Gradle only searches the repositories you list. The Android Gradle plugin is hosted on Google's Maven repository, so it must be listed in pluginManagement (or in buildscript if you use the old style).
grep -n -A6 "pluginManagement\|buildscript" settings.gradle* build.gradle*2Fix
Add google() and mavenCentral() to the plugin repositories.
// settings.gradle.kts
pluginManagement {
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}3Verify
Sync the project again.
./gradlew helpConfirmed by docs.gradle.org
Cause 2 of 3
A proxy or firewall blocks Gradle's download
1Check
Android Studio uses its own HTTP Proxy setting; the command line and CI machines read gradle.properties instead. If the two differ, the IDE works and the terminal fails, or the other way round.
cat ~/.gradle/gradle.properties2Fix
Set the proxy in gradle.properties, for both http and https. Put it in the root project or in the Gradle user home.
systemProp.http.proxyHost=proxy.example.com
systemProp.http.proxyPort=8080
systemProp.https.proxyHost=proxy.example.com
systemProp.https.proxyPort=80803Verify
Re-run the build from the terminal.
./gradlew help --refresh-dependenciesConfirmed by developer.android.com
Cause 3 of 3
Offline mode is on, or the cache holds a failed result
1Check
The message names offline mode when it is switched on, in the IDE's Gradle settings or by an --offline flag.
grep -rn "offline" gradle.properties ~/.gradle/gradle.properties2Fix
Turn offline mode off and force Gradle to check the remote repositories again.
./gradlew build --refresh-dependencies3Verify
The build now downloads the plugin and passes configuration.
./gradlew helpConfirmed by docs.gradle.org
How do I stop it coming back?
- Keep google(), mavenCentral() and gradlePluginPortal() in pluginManagement from the first commit.
- Pin the Android Gradle plugin to a released version, never a dynamic one such as 8.+.
- Put proxy settings in one place per machine and document them for CI.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Mobile apps
adb cannot start because something already holds its port
adb start-server failed
The adb server must bind local TCP port 5037, and every adb client talks to it there.
2 causes, each with a fixMobile apps
The phone shows as unauthorized and Android Studio will not run the app
adb devices lists the phone but Android Studio cannot deploy to it
An unauthorized phone means it has not trusted this computer's RSA key.
3 causes, each with a fixMobile apps
Android Studio cannot pair the phone over Wi-Fi
The Pair devices over Wi-Fi dialog lists no device
Wireless pairing needs the phone on Android 11 or higher and on the same Wi-Fi network as the computer, with current Platform-Tools.
4 causes, each with a fixMobile apps
adb cannot connect to its daemon or start the server
* daemon started successfully *
The adb server is a background process on your computer that listens on TCP port 5037.
2 causes, each with a fixMobile apps
adb prints 'server version doesn't match this client; killing...'
adb server version doesn't match this client; killing...
adb runs a background server, and every adb command is a client.
3 causes, each with a fixMobile apps
adb tcpip 5555 fails because no device is found
adb: more than one device/emulator
adb tcpip only works while the device is attached and listed by adb, because it tells the phone to start listening on port 5555.
4 causes, each with a fix