Fix "Could not resolve all files for configuration" and "Could not find" in Gradle
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
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.
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
- 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). - Missing repository: the library is on JitPack, a company repository or the old
jcenter()(shut down), but onlygoogle()andmavenCentral()are declared. - Offline mode enabled (
--offline, Android Studio "Offline" toggle) while the dependency is not in the cache yet. - Corporate network: proxy not configured for Gradle, intercepted TLS certificate, or private repository answering 401 / 403 because of missing credentials.
- Corrupted Gradle cache after an interruption during a download: the file exists remotely but the local entry is broken.
Step-by-step fix
-
Read the cause under the umbrella error
Find the
Could not find …orCould not resolve …line, the list of tried URLs and theRequired byblock. To see where a transitive dependency comes from, usedependencyInsight. On Windows, replace./gradlewwithgradlew.bat../gradlew :app:dependencies --configuration debugRuntimeClasspath ./gradlew :app:dependencyInsight --dependency com.example:lib --configuration debugRuntimeClasspath -
Check that the version exists
Search for the library on
central.sonatype.com(Maven Central) ormaven.google.com(Google) and copy the exact coordinates from its documentation. Beware of versions made up by an AI or of an oldgroupId.// app/build.gradle.kts dependencies { implementation("com.squareup.okhttp3:okhttp:4.12.0") } -
Declare the right repository
In recent projects, repositories are declared in
settings.gradle.kts. WithFAIL_ON_PROJECT_REPOS, arepositoriesblock added inapp/build.gradle.ktsis rejected: add it here. Replacejcenter()withmavenCentral().// settings.gradle.kts dependencyResolutionManagement { repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) repositories { google() mavenCentral() maven { url = uri("https://jitpack.io") } } } -
Turn off offline mode and refresh
In Android Studio, turn off "Toggle Offline Mode" in the Gradle window, or remove
org.gradle.offline=truefromgradle.properties. Then force Gradle to check the remote repositories again../gradlew build --refresh-dependencies -
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/cachesalso works but forces a full re-download. On Windows, the cache is in%USERPROFILE%\.gradle\caches../gradlew --stop rm -rf ~/.gradle/caches/modules-2/files-2.1/com.example ./gradlew build -
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 inbuild.gradle.kts.# ~/.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.tomlcatalog 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 withcontent { includeGroup(...) }. - In CI, cache
~/.gradle/caches(for example withgradle/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
- Fix "java.lang.NullPointerException: Cannot invoke … because … is null" in Java
- Fix "UnsupportedClassVersionError: compiled by a more recent version of the Java Runtime"
- Fix "Web server failed to start. Port 8080 was already in use" in Spring Boot
- Fix "Failed to configure a DataSource: 'url' attribute is not specified" in Spring Boot
- Fix "java.lang.OutOfMemoryError: Java heap space" (and GC overhead limit exceeded)
- Fix "Object reference not set to an instance of an object" (NullReferenceException) in C#
- Fix "lateinit property binding has not been initialized" in Kotlin (Android)