Skip to content
Latchkey

Gradle "Could not resolve" Dependency - Fix in CI

Gradle could not locate a dependency in any repository declared in the build. Either the coordinates are wrong, the repository is missing from the repositories {} block, or the artifact is not published where Gradle looked.

What this error means

The build fails during configuration or resolution with Could not resolve <group:name:version> and Could not find/Required by: lines showing the path to the missing artifact. No compilation happens.

gradle output
> Could not resolve com.example:lib:2.3.1.
  Required by:
      project :app
   > Could not find com.example:lib:2.3.1.
     Searched in the following locations:
       - https://repo.maven.apache.org/maven2/com/example/lib/2.3.1/lib-2.3.1.pom

Common causes

Repository not declared

Gradle only searches repositories you list in repositories {}. An internal or vendor artifact is invisible unless that repo (and its credentials) is declared.

Wrong coordinates or version

A typo in group/name or a version that was never published means no repository can serve it.

How to fix it

Declare the repository that holds the artifact

Add the hosting repository to the build’s repositories block.

build.gradle.kts
repositories {
    mavenCentral()
    maven {
        url = uri("https://nexus.example.com/repository/maven-releases/")
    }
}

Inspect the resolution path

See exactly which configuration pulls the dependency and where Gradle searched.

Terminal
./gradlew :app:dependencyInsight --dependency com.example:lib
./gradlew :app:dependencies --configuration runtimeClasspath

How to prevent it

  • Declare all repositories (including internal) centrally in settings.gradle dependencyResolutionManagement.
  • Use a version catalog so coordinates are defined once and reused.
  • Cache the Gradle dependency cache in CI keyed on the lockfile/build scripts.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →