Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use google-services.json and Google Maps API key?

An app uses Firebase and Google Maps Android SDK.

Firebase works fine by using the google-services.json file downloaded on the Firebase console.

However the Google Maps API key is provided in the AndroidManifest.xml file with:

<meta-data
   android:name="com.google.android.geo.API_KEY"
   android:value="${google_maps_key}" />

while the google maps key is provided in build.gradle according to build variant:

manifestPlaceholders.google_maps_key = "<REMOVED>";

The Google Maps feature works in debug build variant but it doesn't work in release. The APIs in the Google Cloud Console are enabled and the credentials are correct (SHA1 fingerprints, API restrictions). The Google Cloud console does not show any API requests for the release project.

The google-services.json contains an API key that I did not find anywhere in the Google Cloud console or Firebase ("api_key": [{ "current_key": <REMOVED> }]).

Is is possible that JSON file conflicts with the Google Maps API key?

like image 343
Manuel Avatar asked Nov 04 '18 19:11

Manuel


People also ask

What is API key in Google services JSON?

An API key is a unique string that's used to route requests to your Firebase project when interacting with Firebase and Google services.

Can I use Google Maps API without API key?

Googlemaps API key is required for built-in theme map element as it offers advanced options for map style, zoom and marker. However, you may use a standard Google Maps block of WPBakery or Elementor page builder to set up Google maps without API key.

Will Google provide Google map service and geocoding service without a key?

You must include an API key with every Geocoding API request.


1 Answers

You can use the following, note that google_api_key will be automatically generated with google-services.json if you use google-play gradle plugin (i.e. id("com.google.gms.google-services"))

<meta-data
    android:name="com.google.android.geo.API_KEY"
    android:value="@string/google_api_key" />
like image 57
Saba Avatar answered Oct 05 '22 05:10

Saba