Home » Android » android – Google Maps API Key in release build doesn't work

android – Google Maps API Key in release build doesn't work

Posted by: admin May 14, 2020 Leave a comment

Questions:

I’m currently developing an application for Android and I’m using Google Maps API. In developer console, I added my SHA1 certificate print, followed by my package name.
Even though I put this SHA1 certificate print using keytool, I can’t access to the maps.
I made lots of search, but every topics brought me to answers where error were in a wrong API Key in developer console.
But I took the right SHA1, the one of my certificate.

Thanks in advance !

How to&Answers:

I had this same problem, it was super frustrating. What I ended up doing was taking the key I made using my release keystore and putting it in the google developers console. Then, added the following into the android manifest.

<meta-data
        android:name="com.google.android.geo.API_KEY"
        android:value="KEY GOES HERE"/>

I’m sure you read the documentation on this, but make sure you follow the instructions for the release certificate to the dot.

https://developers.google.com/maps/documentation/android/signup

You could also follow the link that was generated for you in the google_maps_api.xml file. This automates the process of entering the key into the developer console. However, make sure you still add that meta data value into your manifest.

Answer:

My Map in release mode was showing but after I publish to Play Store it was not showing.

I had mentioned both debug and release certificate SHA-1 Key to Google Developer Console but map in release mode after downloading app from play store was still not showing.

Here’ what was problem:
Google Play App Signing is enabled for this app

Goto Release Management -> App Signing -> and copy the SHA-1 certificate fingerprint from App signing certificate

Paste this newly copied SHA-1 fingerprint to Developer Console and map in release mode will show.

Answer:

The file google_maps_api.xml has to be under res/debug/ and res/release. The editor only shows your current run configuration which is debug by default and is a bit misleading if you do not observe the (debug) note after the folder name. Copy the google_maps_api.xml into both folder and edit make sure they have the correct API keys ofr each build.

Answer:

Android Studio also creates a TODO in the release folder for the google_maps_api xml file and lets you know of the required procedure before release. Also please do not change the key in manifest manually. When you switch to a release variant, the key is automatically updated in the manifest.

In any case do this,

  1. Go to the link as mentioned by @Andrew Brook

  2. Click “Get a key” and continue

  3. Either create a new project or use an existing one
  4. Specify the options and click the button
  5. If you already had made one before, for let’s say for debug, then go to Create a new api key
    Image here
  6. Add the required name, click on “Add package name and fingerprint”
  7. Add your app’s package name and SHA-1 key (generete it using keytool in java/jdk../bin/)
    Image here
  8. You get your “release” variant API key to be added in the google_maps_api.xml in the release folder.

Answer:

You have to Enable the SHA key In Google Developer Console
so at 1st go to release Management get your app SHA key (1st one )
then Follow this link

 https://console.developers.google.com/flows/enableapi?apiid=maps_android_backend&keyType=CLIENT_SIDE_ANDROID&r=(Your SHA KEY)%3B(YOUR PACKAGE NAME)

Now it Will Enable the API .
now update your app with the new key .
It will Work .