32

I applied the exact steps as mentioned in the google developer doc to create an example google map project and everything went fine on the emulator, but when I generated the project apk file and launched it on real device Samsung Galaxy S4 google map doesn't show up it shows only a blank background with just colored Google logo appearing on the left lower screen corner !!

I created new project for google map I created new .jks file for the project and created store and key pass and alias then I extracted the SHA1 from cmd java bin I went to dev.google.com/console created new project then enabled google maps android API then created API key from Credentials pasted this API key in place in google_maps_api.xml in my project updated the signingConfigs release with the .jks file path and alias and two passwords. then generated signed APK from Android Studio then transferred the app-release.apk to real device then installed it same problem google map NOT showing.

Zoe
  • 23,712
  • 16
  • 99
  • 132
user2985035
  • 509
  • 2
  • 7
  • 16

9 Answers9

44

Reason for this issue

This occurred because there are different SHA1s in debug and release types.

Fix for this issue

Add the SHA1 of the keystore used to build the release APK to Google console

Steps:

  1. Get the path of the keystore when you generate signed APK

    Build ----> Generate Signed APK..

Save the key store path

enter image description here

Remember to make Build Type --- release

enter image description here

  1. Extract SHA1 from the keystore.

Open your terminal use command below:

 keytool -list -v -keystore "/Users/NT/Desktop/generalkey.jks"

You will be asked for password for your keystore.

Change path to your keystore path keytool -list -v -keystore "keystore path"

From the Certificate fingerprints, you will see the SHA1

  1. Generate android key using this SHA1 and your package name

enter image description here

Generate APK using keystore and enjoy your map

SQLiteNoob
  • 2,662
  • 3
  • 25
  • 43
Mina Fawzy
  • 18,268
  • 13
  • 118
  • 129
  • make sure you get the Sha1 from the used key to release, and add to gcm or firebase console – Mina Fawzy May 07 '18 at 11:30
  • The last part of the answer is not clear to me. Generate android key using this SHA1... Where we have to create that key? Google android API Key or Keystore in Android Studio? Thanks! – Maseed Aug 15 '18 at 03:45
  • 1
    In step 3 the SHA1 extracted from the keystore (step 2) needs to be added in the Google Developers Console under Credentials (https://console.developers.google.com). Look for the same "google_maps_key" from your Android project (google_maps_api.xml), it starts with "AIza". Then click on it in the Google Developer Console then add the additional SHA1 from step 2. Hope this helps, it had me confused me initially. – Roj Dec 22 '18 at 14:51
  • 3
    I also had app signing enabled in Google Play Console so also added the SHA1 found in Google Play Console under "Release Managment" -> "App Signing". I think it was actually this SHA1 that got the maps working again in my app. https://stackoverflow.com/questions/46191073/google-maps-not-showing-after-uploading-the-app-to-playstore/46191310#46191310 – Roj Dec 22 '18 at 15:06
  • indeed, if you use app signing by google play, you'll need to use "App signing certificate", not "Upload certificate" – Leo Chen Apr 12 '19 at 03:39
  • I only get this: `Certificate fingerprint (SHA-256): [value...]`. Why is it that I do not get a `SHA1`? – Jaime Montoya May 25 '19 at 05:15
  • 1
    Only solution that worked – coolcool1994 Feb 14 '21 at 17:59
19

It might be silly but I had my API key included in

app\src\debug\res\values\google_maps_api.xml (debug)

You also need to include in-

app\src\release\res\values\google_maps_api.xml (release)

Varun Kumar
  • 1,589
  • 16
  • 17
7

if any one still facing this problem :

this happend to me because we need two google maps api keys one for the debug and another one for the release, you can check in :

C:\Users\username\AndroidStudioProjects\yourapp\app\src\ debug \res\values and you'll find an xml with your api key like:

    <string name="google_maps_key" templateMergeStrategy="preserve" 
          translatable="false">AIza...etc</string>

but if you check here:

C:\Users\username\AndroidStudioProjects\yourapp\app\src\ release \res\values you will find an xml but without api key inside like:

     <string name="google_maps_key" templateMergeStrategy="preserve" 
         translatable="false">YOUR_KEY_HERE</string>

it was noted as a comment inside the xml file itself :

Before you release your application, you need a Google Maps API key.

To do this, you can either add your release key credentials to your existing
key, or create a new key.

Note that this file specifies the API key for the release build target.
If you have previously set up a key for the debug target with the debug signing certificate,
you will also need to set up a key for your release certificate.

Follow the directions here:

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

Once you have your key (it starts with "AIza"), replace the "google_maps_key"
string in this file.
ehab
  • 119
  • 1
  • 9
4

Check the following things:

  • This below file should be in both debug and release

    app\src\debug\res\values\google_maps_api.xml (debug)
    

    You also need to include in

    app\src\release\res\values\google_maps_api.xml (release)
    
  • Add the SHA1 for release apk into Google Api Console.
    You can get SHA1 key from play console >> App Signing >> SHA1 Certificate

barbsan
  • 3,238
  • 11
  • 18
  • 27
Govind Prajapati
  • 198
  • 2
  • 10
3

now google signed apk before publish on store,so go to google pushish app ---> app signning , and add signed key to google developer console,you shoud add 3 key sha1 : debug,release and new sha1 key after pushlish

Long Bui Duc
  • 434
  • 3
  • 10
  • 3
    Welcome to SO. Please read this [how-to-answer](http://stackoverflow.com/help/how-to-answer) and follow the guideline there to provide quality answer. – thewaywewere Jun 17 '17 at 11:48
3

Another additional step: In google play developer console add App Signing SHA1 fingerprint: enter image description here

1

For showing the map in release version of android apk, developer needs to add the updated SHA-1 key, created by Google Play console after publishing the application. Go to App Signing section of the console and look for 'App Signing Certificate: SHA-1 Certificate Fingerprint'. Copy the fingerprint and paste it in Google API Console where developer has created the Google API key for map.

Parita Dey
  • 11
  • 1
0

for all those out there who tried every thing and still not getting the google map to show up in the release version, try to first:

1- install the release.apk on your phone or emulator

2- open the logcat window and set it on your phone device (if using emulator its set on it by default)

3- open the map and it shows the error like below, copy the key and paste in the value tag below in the Manifest file :

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

the actual key from logcat

narcis dpr
  • 393
  • 2
  • 10
  • 27
-2

I also had the same issue of map when I'm making the apk , make apk in the same system in which system you have made the google map key then the map will work and show perfectly .

Umair Khan
  • 41
  • 3