Maaz Zindani

Loading the index…

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

Android build: package com.google.android.gms... does not exist

Errorpackage com.google.android.gms... doesn't exist

Short 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.

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

Fix it fast

  1. 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.kts
  2. 2Match what you see, then jump to its fix

    1. 1The 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. 2play-services is present in the top-level build file, not in the app moduleThe dependency sits in the wrong build fileFix
    3. 3Sync reports it cannot resolve com.google.android.gms:play-services-...Gradle does not search Google's Maven repositoryFix

What does the error look like?

  • package com.google.android.gms... doesn't exist
  • Build 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.kts

2Fix

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 assembleDebug

Confirmed by developers.google.com

Did this fix it?

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 assembleDebug

Confirmed by developers.google.com

Did this fix it?

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 assembleDebug

Confirmed by developers.google.com

Did this fix it?

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

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

Mobile 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

Next step

Want this handled for good?

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