Skip to content
  1. LuzineDebug
  2. Java, Kotlin & .NET
  3. FAILURE: Build failed with an exception.
Java, Kotlin & .NET Intermediate ≈ 15 min to fix

Fix "Could not resolve all files for configuration" and "Could not find" in Gradle

Error message
FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
   > Could not find com.example:lib:1.0.
     Searched in the following locations:
       - https://dl.google.com/dl/android/maven2/com/example/lib/1.0/lib-1.0.pom
       - https://repo.maven.apache.org/maven2/com/example/lib/1.0/lib-1.0.pom
     Required by:
         project :app
  • Could not resolve all dependencies for configuration ':app:debugCompileClasspath'.
  • Could not resolve com.example:lib:1.0. > Could not GET 'https://jitpack.io/com/example/lib/1.0/lib-1.0.pom'. Received status code 401 from server: Unauthorized
  • No cached version of com.squareup.okhttp3:okhttp:4.12.0 available for offline mode.
  • Could not resolve all artifacts for configuration ':classpath'.
  • [ERROR] Failed to execute goal on project app: Could not resolve dependencies for project com.example:app:jar:1.0: Could not find artifact com.example:lib:jar:1.0 in central
In short

Gradle could not find a dependency in any of the declared repositories. Check that the group:name:version coordinates really exist, that the right repository (google(), mavenCentral(), JitPack…) is declared in settings.gradle.kts, then turn off offline mode and run again with --refresh-dependencies.

Be the first to confirm this fix

What this error means

Before compiling, Gradle "resolves" each configuration (for example debugRuntimeClasspath, the runtime classpath of the Android debug variant): it looks up every dependency, direct or transitive, in the declared repositories, in order. Could not resolve all files for configuration is the umbrella error; the line below gives the real cause. Could not find means every repository answered without finding the file: the Searched in the following locations list shows where Gradle looked and Required by who asks for that dependency. Could not resolve or Could not GET points instead to a network, proxy, certificate or credentials problem.

Common causes

  1. Coordinates or version that do not exist: typo in the group or name, a version that was never published, or a renamed library (new groupId).
  2. Missing repository: the library is on JitPack, a company repository or the old jcenter() (shut down), but only google() and mavenCentral() are declared.
  3. Offline mode enabled (--offline, Android Studio "Offline" toggle) while the dependency is not in the cache yet.
  4. Corporate network: proxy not configured for Gradle, intercepted TLS certificate, or private repository answering 401 / 403 because of missing credentials.
  5. Corrupted Gradle cache after an interruption during a download: the file exists remotely but the local entry is broken.

Step-by-step fix

  1. Read the cause under the umbrella error

    Find the Could not find … or Could not resolve … line, the list of tried URLs and the Required by block. To see where a transitive dependency comes from, use dependencyInsight. On Windows, replace ./gradlew with gradlew.bat.

    bash
    ./gradlew :app:dependencies --configuration debugRuntimeClasspath
    ./gradlew :app:dependencyInsight --dependency com.example:lib --configuration debugRuntimeClasspath
  2. Check that the version exists

    Search for the library on central.sonatype.com (Maven Central) or maven.google.com (Google) and copy the exact coordinates from its documentation. Beware of versions made up by an AI or of an old groupId.

    kotlin
    // app/build.gradle.kts
    dependencies {
        implementation("com.squareup.okhttp3:okhttp:4.12.0")
    }
  3. Declare the right repository

    In recent projects, repositories are declared in settings.gradle.kts. With FAIL_ON_PROJECT_REPOS, a repositories block added in app/build.gradle.kts is rejected: add it here. Replace jcenter() with mavenCentral().

    kotlin
    // settings.gradle.kts
    dependencyResolutionManagement {
        repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
        repositories {
            google()
            mavenCentral()
            maven { url = uri("https://jitpack.io") }
        }
    }
  4. Turn off offline mode and refresh

    In Android Studio, turn off "Toggle Offline Mode" in the Gradle window, or remove org.gradle.offline=true from gradle.properties. Then force Gradle to check the remote repositories again.

    bash
    ./gradlew build --refresh-dependencies
  5. Purge the corrupted cache entry

    Stop the Gradle daemons, delete only the folder of the affected library in the cache, then rebuild. Deleting all of ~/.gradle/caches also works but forces a full re-download. On Windows, the cache is in %USERPROFILE%\.gradle\caches.

    bash
    ./gradlew --stop
    rm -rf ~/.gradle/caches/modules-2/files-2.1/com.example
    ./gradlew build
  6. Configure the proxy or credentials

    Behind a proxy, declare it in ~/.gradle/gradle.properties (not in the Git repository). For a private repository, put the credentials in that same file or in environment variables, never in plain text in build.gradle.kts.

    ini
    # ~/.gradle/gradle.properties
    systemProp.https.proxyHost=proxy.company.com
    systemProp.https.proxyPort=8080
    systemProp.http.proxyHost=proxy.company.com
    systemProp.http.proxyPort=8080
    companyRepoUser=me
    companyRepoPassword=token-from-your-repo

Did this fix work for you?

Confirm it in one click: it will rise for the next developers stuck on the same error.

Keep it from coming back

  • Centralise versions in a gradle/libs.versions.toml catalog to avoid typos and diverging versions between modules.
  • Declare all repositories in settings.gradle.kts, from the most trusted to the most specific, and restrict third-party repositories with content { includeGroup(...) }.
  • In CI, cache ~/.gradle/caches (for example with gradle/actions/setup-gradle) to reduce downloads and network failures.

Frequently asked questions

What does debugRuntimeClasspath mean?

It is the list of libraries needed to run the debug variant of the :app module. The error does not necessarily come from your code: a transitive dependency may be missing, which is why the Required by block helps.

Why does it work on a teammate’s machine and not on mine?

They probably have the dependency in their Gradle cache, downloaded when it was available (jcenter, internal repository). On a fresh machine or in CI, Gradle must find it online and fails.

What about the Maven equivalent?

Maven prints "Could not resolve dependencies for project" then "Could not find artifact". Check the coordinates and the repositories in pom.xml or ~/.m2/settings.xml the same way, then run ./mvnw -U clean package to force an update.

Useful tools for this error

More Java, Kotlin & .NET errors

All Java, Kotlin & .NET errors →