Gradle cannot resolve com.facebook.android:facebook-android-sdk with a version range
Failed to resolve: com.facebook.android:facebook-android-sdk:[4,5)Short answer
Gradle can only resolve the Facebook SDK from a repository that is declared in your build. The usual causes are a missing mavenCentral() entry, or a version range whose bounds match nothing you can download. Declare mavenCentral() in the repositories block, then use a fixed version, or latest.release as Facebook's own guide shows.
Fix it fast
1Find out which cause you have
Print the dependency declaration and the repositories next to each other. The SDK must be declared once, and at least one declared repository must host it.
grep -rn "facebook-android-sdk" --include=*.gradle --include=*.kts . grep -rn -B2 -A6 "repositories" settings.gradle* build.gradle*2Match what you see, then jump to its fix
What does the error look like?
Failed to resolve: com.facebook.android:facebook-android-sdk:[4,5)Failed to resolve: com.facebook.android:facebook-android-sdk
Cause 1 of 2
mavenCentral() is not in the repositories block
1Check
Facebook's setup guide tells you to add mavenCentral() to the repositories. Gradle only searches repositories that are declared, in the order they appear, so a project with only google() cannot find the SDK.
grep -rn "mavenCentral\|google()" settings.gradle* build.gradle*2Fix
Add mavenCentral() to the repositories block, as Facebook's guide shows.
repositories {
google()
mavenCentral()
}3Verify
Sync again; the dependency should show up under the module's runtime classpath.
./gradlew :app:dependencies --configuration releaseRuntimeClasspath | grep -i facebookConfirmed by developers.facebook.com
Cause 2 of 2
The version range excludes every version you can download
1Check
In Gradle's range syntax a square bracket includes the bound and a round bracket excludes it, so [4,5) means 4 up to but not including 5. A range only works if a published version falls inside it in a repository you declared.
grep -rn "facebook-android-sdk" --include=*.gradle --include=*.kts .2Fix
Replace the range with one fixed version from the SDK's release notes, or use the form Facebook's own guide shows. A fixed version also makes builds repeatable, which Android's build guide recommends over dynamic versions.
// Facebook's documented form
implementation("com.facebook.android:facebook-android-sdk:latest.release")
// or pin one release you have checked
// implementation("com.facebook.android:facebook-android-sdk:<version>")3Verify
Run a sync and a debug build; Gradle should print one resolved version.
./gradlew :app:assembleDebugConfirmed by docs.gradle.org
How do I stop it coming back?
- Keep one clear place where repositories are declared, with mavenCentral() and google() in it.
- Pin SDK versions instead of using ranges or plus signs.
- Read the Facebook SDK release notes before raising the version, because newer majors change setup.
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
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 fixMobile apps
adb tcpip 5555 fails because no device is found
adb: more than one device/emulator
adb tcpip only works while the device is attached and listed by adb, because it tells the phone to start listening on port 5555.
4 causes, each with a fix