Mr.AndroidShin / Dev Tools

Debugging log · Gradle

"Could not resolve" a dependency

Gradle sync stopped with Could not resolve com.example:library:1.0.0. It had compiled yesterday; today it couldn't even find the library. "Resolve" here means "locate and download," and when it fails, the library either isn't where Gradle is looking, isn't named what you typed, or Gradle couldn't reach the internet to fetch it. Four causes, each with a quick check.

The short version: Gradle looked for the artifact in your declared repositories and didn't get it. Check, in order: is the repository declared, are the coordinates and version exactly right, does that version exist, and can your machine actually reach the repository. One of those four is almost always it.

The error

Could not resolve com.example:library:1.0.0.
  Required by: project :app
> Could not find com.example:library:1.0.0.
  Searched in the following locations: ...

That "Searched in the following locations" list is gold — it shows exactly which repositories Gradle checked. If the repository that hosts your library isn't in that list, you've found the cause immediately.

Cause 1 — the repository isn't declared

Gradle only searches repositories you've told it about. Most libraries live in Maven Central or Google's Maven; a few live elsewhere (a vendor's own Maven, JitPack). If the hosting repository isn't declared, the artifact can't be found. In a modern project, repositories are usually in settings.gradle:

dependencyResolutionManagement {
    repositories {
        google()
        mavenCentral()
        // maven { url = uri("https://jitpack.io") }  // if the lib needs it
    }
}

Add the repository the library actually lives in. A JitPack-hosted dependency, for instance, fails with this exact error until you add the JitPack repo.

Cause 2 — a typo in the coordinates

The coordinates are group:artifact:version, and a single wrong character makes the artifact unfindable. Copy the exact line from the library's official docs rather than typing it. Watch for a wrong group, a misspelled artifact name, or -ktx / platform suffixes that do or don't belong. "Could not find" with correct-looking coordinates is very often a subtle typo.

Cause 3 — that version doesn't exist

The group and artifact are right but the version isn't published — a number you guessed, a typo, or a version yanked from the repository. Check the library's releases for a version that actually exists and use that. Pinning to a version that was never published fails the same way as a typo.

Cause 4 — a network or proxy block

If everything is declared and spelled correctly, Gradle may simply not be reaching the repository. Behind a corporate proxy or firewall, or offline, downloads fail and surface as "could not resolve." Confirm you have internet, that you're not in Gradle offline mode (a toggle that's easy to leave on), and that any proxy is configured. On a locked-down network this is frequently the real cause, not your build file.

Read the "Searched in the following locations" list before changing anything. It tells you whether the problem is where Gradle looked (repository) or what it looked for (coordinates/version) — which cuts the four causes down to the one you actually have.

A quick decision path

Coordinates and versions above are examples — use the exact ones from your library's documentation.