Android Studio cannot resolve a com.github.* library that comes from JitPack or JCenter
Failed to resolve: com.github.barteksc:android-pdf-viewer:3.2.0-beta.1Short 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.
Fix it fast
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 debugRuntimeClasspath2Match what you see, then jump to its fix
- 1
The searched list shows Google and Maven Central but not jitpack.ioThe JitPack repository is not declared where the build reads itFix - 2
jitpack.io is searched and the artifact is still not foundThe tag, commit or version in the coordinates does not exist on JitPackFix - 3
An 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
- 1
What does the error look like?
Failed to resolve: com.github.barteksc:android-pdf-viewer:3.2.0-beta.1Could 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/null2Fix
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 githubConfirmed by docs.jitpack.io
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 githubConfirmed by docs.jitpack.io
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:assembleDebugConfirmed by developer.android.com
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
Gradle cannot resolve the files of :app:debugRuntimeClasspath after adding a dependency
Could not find com.example:library:1.0.0.
After you add a dependency, Gradle must download it and everything it needs.
3 causes, each with a fixMobile apps
adb cannot start because something already holds its port
adb start-server failed
The adb server must bind local TCP port 5037, and every adb client talks to it there.
2 causes, each with a fixMobile apps
The phone shows as unauthorized and Android Studio will not run the app
adb devices lists the phone but Android Studio cannot deploy to it
An unauthorized phone means it has not trusted this computer's RSA key.
3 causes, each with a fixMobile 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 fixMobile apps
adb cannot connect to its daemon or start the server
* daemon started successfully *
The adb server is a background process on your computer that listens on TCP port 5037.
2 causes, each with a fixMobile apps
adb prints 'server version doesn't match this client; killing...'
adb server version doesn't match this client; killing...
adb runs a background server, and every adb command is a client.
3 causes, each with a fix