Maaz Zindani

Loading the index…

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

Android Studio cannot resolve a com.github.* library that comes from JitPack or JCenter

ErrorFailed to resolve: com.github.barteksc:android-pdf-viewer:3.2.0-beta.1

Short answer

Gradle only searches the repositories you list. A com.github.* dependency is served by JitPack or was once on JCenter, and neither is in a new project by default. Add JitPack to settings.gradle, use a tag that exists, and if the library only ever lived on JCenter, switch to a maintained fork that JitPack can build.

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

Fix it fast

  1. 1Find out which cause you have

    Open the error in the Build window and read which repositories Gradle listed as searched. If jitpack.io is not among them, the first cause applies.

    ./gradlew :app:dependencies --configuration debugRuntimeClasspath
  2. 2Match what you see, then jump to its fix

    1. 1The searched list shows Google and Maven Central but not jitpack.ioThe JitPack repository is not declared where the build reads itFix
    2. 2jitpack.io is searched and the artifact is still not foundThe tag, commit or version in the coordinates does not exist on JitPackFix
    3. 3An old guide shows a com.github dependency with no JitPack line, and no repository you can add has itThe library was published only to JCenter, which is read-onlyFix

What does the error look like?

  • Failed to resolve: com.github.barteksc:android-pdf-viewer:3.2.0-beta.1
  • Could not find com.github.User:Repo:Tag

Cause 1 of 3

The JitPack repository is not declared where the build reads it

1Check

New Android Studio projects set repositoriesMode to FAIL_ON_PROJECT_REPOS, so repositories belong in the dependencyResolutionManagement block of settings.gradle. JitPack's own guide places its entry there, at the end of the list.

grep -n -A8 "dependencyResolutionManagement" settings.gradle settings.gradle.kts 2>/dev/null

2Fix

Add JitPack after google() and mavenCentral() in the settings file, then sync.

// settings.gradle.kts
dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
        maven { url = uri("https://jitpack.io") }
    }
}

3Verify

Sync the project. The failed to resolve line no longer appears for that artifact.

./gradlew :app:dependencies --configuration debugRuntimeClasspath | grep -i github

Confirmed by docs.jitpack.io

Did this fix it?

Cause 2 of 3

The tag, commit or version in the coordinates does not exist on JitPack

1Check

JitPack builds a GitHub repository on request. The version must be a release tag, a commit hash or master-SNAPSHOT, and the repository needs a build file it can run. Look the repository up on jitpack.io to see which versions built and which failed.

echo "Open https://jitpack.io, paste the GitHub repository URL and look up its versions"

2Fix

Use a version that shows as built, in the form com.github.User:Repo:Version, or ask the maintainer to tag a release.

dependencies {
    implementation("com.github.User:Repo:v1.2.3")
}

3Verify

Sync again; Gradle downloads the artifact from jitpack.io.

./gradlew :app:dependencies --configuration debugRuntimeClasspath | grep -i github

Confirmed by docs.jitpack.io

Did this fix it?

Cause 3 of 3

The library was published only to JCenter, which is read-only

1Check

JCenter, once a default repository, became read-only on 31 March 2021. A library that was never moved to Maven Central or JitPack will not get new versions there and may not resolve in a clean setup.

grep -rn "jcenter" build.gradle* settings.gradle* app/build.gradle*

2Fix

Remove jcenter() and move to a maintained fork of the library, taking its coordinates from the fork's README. Rebuild once the new line is in place.

// settings.gradle.kts: no jcenter() entry
repositories {
    google()
    mavenCentral()
    maven { url = uri("https://jitpack.io") }
}

3Verify

A clean build resolves every dependency without jcenter.

./gradlew clean :app:assembleDebug

Confirmed by developer.android.com

Did this fix it?

How do I stop it coming back?

  • Pin every JitPack dependency to a tag or commit, never to master-SNAPSHOT, for builds you ship.
  • Keep all repositories in settings.gradle so one file shows where artifacts come from.
  • Before adding an old library, check its repository for the date of its last release.

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

Next step

Want this handled for good?

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