Below are a few troubleshooting steps you can take:
1. Check Your API Key Restrictions
Even though you generated a new API key, verify that its restrictions (if any) match your app’s package name and SHA-1 certificate. In many cases, this error occurs when a key meant for Firebase is used with Google Maps. For testing, try using an unrestricted key; once things work, you can apply package and SHA‑1 restrictions:
// In the Google Cloud Console (or Firebase console for Firebase keys)
// Make sure that for non‑Firebase services (like Maps) you’re using an API key with proper restrictions.
// For testing, you might temporarily set "None" under Application Restrictions.
2. Separate API Keys for Firebase and Google Maps
Firebase API keys can have extra restrictions that make them unsuited for calling other APIs (like Maps). It’s recommended to create a dedicated API key for Google Maps with only the necessary restrictions enabled.
3. Verify Your google-services.json
If you’re using Firebase, double‑check that your google‑services.json has the correct package name and SHA‑1 fingerprints. Even though this error mentions Google Play services, an outdated or misconfigured config file can sometimes cause unexpected security exceptions.
4. Use a Device or Emulator with Google Play Services
Since the Maps SDK for Android requires devices with Google Play services, ensure you’re testing on a device (or an emulator that has the Play Store and is CTS‑compliant) rather than a plain Android Virtual Device without Play services.
5. Ignore Non‑Fatal Logcat Warnings
In some cases, the logcat may show “Failed to get service from broker” messages which might be logged internally by Google Play services. If your maps are functioning as expected (markers, camera movement, etc.), these logs might be spurious warnings that do not affect your app’s functionality.
Summary
- Verify that the API key being used for Google Maps is either unrestricted or correctly restricted to your app’s package name and SHA‑1.
- Consider creating separate API keys: one for Firebase and one for Google Maps.
- Double‑check your google‑services.json configuration.
- Test on a device/emulator that has Google Play services installed.
- If functionality isn’t impaired, the logged error may be a harmless warning.
Try these steps and see if they resolve the error. If the maps still fail to load, re‑examine your API key settings in the Google Cloud Console to make sure everything (including quotas, restrictions, and enabling APIs) is correctly configured.