0

I have a Google Maps API Key and it is in both my debug and release google_maps_api.xml files.

The app and map within it work when debugging on a simulator or device. However, when I Generate a signed APK and install it onto a real device, the map is empty, as if there is no Google maps API key specified.

I have tried using the answers on here but non seem to work, at least as far as my experience with Google Play, Android studio, and release builds is allow.

I have gone into Google Play Console and Let Google handle my certificates (or something like that). I now have a list containing MD5 certificate fingerprint SHA-1 certificate fingerprint SHA-256 certificate fingerprint and a button titled [DOWNLOAD CERTIFICATE] (app signing certificate) but have no idea what to do with those... if Im supposed to do anything with them at this point.

What do I do next to get the map to show up on the release signed APK file? Should I plonk the app signing cert somewhere in my project?

My intent is not to release, yet. I just want to test out a release build for performance differences etc.

UPDATE 1 i have followed the following and now have my Certificate Fingerprint, but where do I place it, if at all?


enter image description here


pnizzle
  • 5,359
  • 3
  • 38
  • 70
  • still i think its release SHA1 key fact. if you upload it to google playstore, please find release sha1 from playstore console, put it on the app release sha1,hope it will solved the problem. Few days ago I face the same problem and solved by this way. – Imranrana07 Jan 16 '20 at 05:18
  • @Imranrana07 I am not releasing to play store. I am only building a signed APK for testing. Where do I `put it on the app release sha1`. Where is that? Is that in Play Console? – pnizzle Jan 16 '20 at 05:20
  • did you put any SHA1 key for release variant? – Imranrana07 Jan 16 '20 at 05:22
  • @Imranrana07 I am lost on what you mean sorry. What do you mean; was I supposed to put a SHA1 key during the APK signing setup ? If so, is that the SHA1 from Google Play Console ? – pnizzle Jan 16 '20 at 05:24
  • https://stackoverflow.com/questions/15727912/sha-1-fingerprint-of-keystore-certificate – Imranrana07 Jan 16 '20 at 05:27
  • @Imranrana07 I have the sha1 already now. See the update. But what do i do with it ? – pnizzle Jan 16 '20 at 05:29
  • please check this one, you have to get SHA1 for release and debug apk and put it down to the respective position correctly to show your maps otherwise you map will sho white screen with google log at bottom. – Imranrana07 Jan 16 '20 at 05:30
  • @Imranrana07 okay, I have the SHA1. But what do I do with it is the next the question? – pnizzle Jan 16 '20 at 05:31
  • then goto project from left bar option in the android studio, and in release folder there are option to put release sha1, put it and generate signed apk again then it will work on real device – Imranrana07 Jan 16 '20 at 05:36
  • @Imranrana07 sure. But first, am i putting the SHA1 from Play Console? Or the sha1 generated from the the first build? I assume from Console? Logic is against the later... – pnizzle Jan 16 '20 at 05:37
  • you can find SHA1 from your android studio or command prompt, – Imranrana07 Jan 16 '20 at 05:39
  • https://imgur.com/2UogMBC here is a screenshot where you have to put your release SHA1 – Imranrana07 Jan 16 '20 at 05:42
  • @Imranrana07 so it goes into the google_maps_api.xml file? And whats the format there ? – pnizzle Jan 16 '20 at 05:44
  • @Imranrana07 100% new. – pnizzle Jan 16 '20 at 05:49
  • @Imranrana07 do i replace the key in the google_maps_api.xml file, or add a completely new row in there? This is so confusing. I have a sha1 in console and a sha1 from terminal, have no idea which to use – pnizzle Jan 16 '20 at 05:50
  • okay. take maps activity during creating new activity and follow this tutorial https://developers.google.com/maps/documentation/android-sdk/start – Imranrana07 Jan 16 '20 at 05:51
  • @Imranrana07 I have a fully functioning app at this point. I am not stuck on the programming part of things. Its just this signing business that doesnt seem to be straight forward. The development side of things I am fine. – pnizzle Jan 16 '20 at 05:53
  • i understand. there showing how to show maps, gets sha1. – Imranrana07 Jan 16 '20 at 05:54
  • actually the process is, after getting sha1 you have to register it with package name into the google console, then you will get a release api key from there, and put it to the marked xml file. then your maps will works. – Imranrana07 Jan 16 '20 at 05:56
  • @Imranrana07 I figured it out eventually. Thanks for your time. – pnizzle Jan 16 '20 at 07:11
  • @Imranrana07 in response to this: `then goto project from left bar option in the android studio, and in release folder there are option to put release sha1, put it and generate signed apk again then it will work on real device` Doing that does nothing actually. The build version already has an unchangeable sha1, the release version too. There the release sha1 has to be added to the API key restrictions list. Thanks again. – pnizzle Jan 16 '20 at 07:13
  • i told you summary, as you are new that is why you could not relate properly, that is why i refer you the link for details. anyway you make it successful that is good. – Imranrana07 Jan 16 '20 at 08:58

1 Answers1

1

Holly Molly, I ended up figuring out that the link in my dubug google_maps_api.xml contains the debug SHA-1 which it passes to Google Cloud Platform to whitelist the debug build for using the GoogleMaps api key that it will use.

This therefore means that if you build a release APK, the SHA-1 will be different.

How do you get the Release SHA-1? You do your Build->Generate Signed Bundle and follow the steps. Take note of where the .keystore file is saved. I used desktop.

Once you have done that, have a look at the screenshot in my question. It states using keytool -list ...etc to view the SHA-1 for the generated APK.

Once you have your SHA-1 showing, go to Google Cloud Platform, and into APIs, and into Maps SDK for Android. Click on the edit icon for the app that you wish to use the API for. You should now see a list titled API restrictions where there should be a list already containing the SHA-1 for your debug build.

Copy your SHA-1 from Terminal, (found by running that keytool -list ...etc) command. Paste it as a new 'item' in that Android app restrictions list. Save, if there is a save button.

You should be good to go from here on .


Or you could just un-restrict your API key usage, which is not recommended.

pnizzle
  • 5,359
  • 3
  • 38
  • 70