Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Flutter and app store releases

Gradle fails to resolve the buildscript classpath, so the build never starts

ErrorCould 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.

  • Applies to Gradle 8.x, Gradle 9, Android Gradle plugin 8.x, Android Studio
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 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 --stacktrace
  2. 2Match what you see, then jump to its fix

    1. 1Could 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. 2Could not GET ... Connect to ... failed or Read timed out, on a network with a proxyA proxy or firewall blocks Gradle's downloadFix
    3. 3Offline mode is switched on in the IDE or the build runs with --offlineOffline mode is on, or the cache holds a failed resultFix

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 help

Confirmed by docs.gradle.org

Did this fix it?

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.properties

2Fix

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=8080

3Verify

Re-run the build from the terminal.

./gradlew help --refresh-dependencies

Confirmed by developer.android.com

Did this fix it?

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.properties

2Fix

Turn offline mode off and force Gradle to check the remote repositories again.

./gradlew build --refresh-dependencies

3Verify

The build now downloads the plugin and passes configuration.

./gradlew help

Confirmed by docs.gradle.org

Did this fix it?

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

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 fix

Mobile 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

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.