Android build: package com.google.android.gms... does not exist
package com.google.android.gms... doesn't existShort answer
Each Google Play services API is its own library. If the matching play-services artifact is not in the app module's dependencies, its package does not exist at compile time. Add the artifact for the API you import, make sure google() is in the repositories, then sync Gradle.
Fix it fast
1Find out which cause you have
See which gms packages your code imports, then see which play-services libraries the app module declares. Each import needs its own library.
grep -rhn "import com.google.android.gms" app/src | sort -u grep -n "play-services" app/build.gradle app/build.gradle.kts2Match what you see, then jump to its fix
- 1
The grep shows an import such as com.google.android.gms.maps with no play-services-maps lineThe play-services artifact for that API is missingFix - 2
play-services is present in the top-level build file, not in the app moduleThe dependency sits in the wrong build fileFix - 3
Sync reports it cannot resolve com.google.android.gms:play-services-...Gradle does not search Google's Maven repositoryFix
- 1
What does the error look like?
package com.google.android.gms... doesn't existBuild fails because a package under com.google.android.gms cannot be found
Cause 1 of 3
The play-services artifact for that API is missing
1Check
Artifacts follow the pattern com.google.android.gms:<artifact>:<version>, one per API (maps, auth, location and so on).
grep -n "play-services" app/build.gradle app/build.gradle.kts2Fix
Add the artifact for the API you use to the dependencies block of the app module, and use the version the Google docs list for that API.
dependencies {
implementation "com.google.android.gms:play-services-maps:20.1.0"
}3Verify
Sync the project; the import turns normal in the editor and the build passes.
./gradlew assembleDebugConfirmed by developers.google.com
Cause 2 of 3
The dependency sits in the wrong build file
1Check
The setup guide says to edit the build file of the app module, not the top-level project file.
grep -rn "play-services" build.gradle* app/build.gradle*2Fix
Move the implementation line into app/build.gradle (or app/build.gradle.kts) and remove it from the top-level file.
// app/build.gradle.kts
dependencies {
implementation("com.google.android.gms:play-services-maps:20.1.0")
}3Verify
Sync again and build.
./gradlew assembleDebugConfirmed by developers.google.com
Cause 3 of 3
Gradle does not search Google's Maven repository
1Check
Look at the repositories block in settings.gradle(.kts).
grep -n -A6 "dependencyResolutionManagement" settings.gradle*2Fix
Add google() and mavenCentral() to the repositories in the settings file, then sync.
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)
repositories {
google()
mavenCentral()
}
}3Verify
Sync the project and run the build.
./gradlew assembleDebugConfirmed by developers.google.com
How do I stop it coming back?
- Add only the play-services libraries you use; each one adds size.
- Copy the artifact name and version from the Google docs for the API, not from old code.
- Sync Gradle after every dependency change.
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