Gradle cannot resolve a Google Play services library
Failed to resolve: com.google.android.gms:play-services-auth:11.4.0Short answer
Play services libraries live in Google's Maven repository, so Gradle can only resolve them when google() is in your repositories block and the version you asked for is still published there. Add google(), then switch to the current version listed in the Play services setup guide.
Fix it fast
1Find out which cause you have
Print the dependency report for the module. The line marked FAILED (or with (n)) names the exact artifact Gradle could not find.
./gradlew :app:dependencies --configuration releaseRuntimeClasspath2Match what you see, then jump to its fix
- 1
Only com.google.android.gms artifacts fail, while Maven Central libraries resolve fineGoogle's Maven repository is not in the buildFix - 2
google() is present but one old version number such as 11.4.0 still failsThe version you asked for is not in Google's Maven repositoryFix - 3
The build fails with a repository error right after you add google() to a module's build fileA repository declared in the module is rejected by the settings fileFix
- 1
What does the error look like?
Failed to resolve: com.google.android.gms:play-services-auth:11.4.0
Cause 1 of 3
Google's Maven repository is not in the build
1Check
Open settings.gradle(.kts) and look in dependencyResolutionManagement { repositories { ... } }. Older projects keep the list in the root build file instead.
grep -n -E "google\(\)|maven.google.com" settings.gradle* build.gradle* 2>/dev/null2Fix
Add google() to the repositories block. Google lists Play services among the libraries hosted there, and the order of repositories decides where Gradle searches first.
// settings.gradle.kts
dependencyResolutionManagement {
repositories {
google()
mavenCentral()
}
}3Verify
Sync the project or run the dependency report again; the artifact no longer shows as failed.
./gradlew :app:dependencies --configuration releaseRuntimeClasspathConfirmed by developer.android.com
Cause 2 of 3
The version you asked for is not in Google's Maven repository
1Check
Google's Maven repository only serves the versions published there; older versions of these libraries are not available. Look up the group's page on maven.google.com to see the versions that exist.
curl -s https://maven.google.com/com/google/android/gms/play-services-auth/group-index.xml | head -c 4002Fix
Use a current version from the Play services setup page instead of the old one. The page lists the coordinate and the latest version for each SDK.
dependencies {
implementation("com.google.android.gms:play-services-auth:22.0.0")
}3Verify
Sync and build; if the new major version changes an API, fix the compile errors it reports.
./gradlew :app:assembleDebugConfirmed by developers.google.com
Cause 3 of 3
A repository declared in the module is rejected by the settings file
1Check
Look at repositoriesMode in settings.gradle(.kts). With FAIL_ON_PROJECT_REPOS, declaring a repository inside a project is a build error.
grep -rn "repositoriesMode" settings.gradle*2Fix
Keep every repository in the settings file and remove the repositories block from the module build file.
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
}
}3Verify
Sync the project again.
./gradlew helpConfirmed by docs.gradle.org
How do I stop it coming back?
- Keep repository declarations in one place, the settings file, and do not repeat them per module.
- Pin one Play services version per library and update it when Google's setup page lists a newer one.
- Avoid dynamic versions such as 11.+, which the Android docs warn against.
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 build: package com.google.android.gms... does not exist
Build fails because a package under com.google.android.gms cannot be found
Each Google Play services API is its own library.
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