Android: Keytool and Google Maps displaying grey

Applies To:
  • Microsoft Windows 7 Pro
  • Android Studio v0.8.6 beta
  • Java Development Kit v1.8.0_20

The article below serves as a checklist to ensure I don't release an app that only displays maps to myself (again).

This took me a while to figure out so hopefully this will help others.

The gist is that I was using the Test SHA1 when adding allowed Android Keys to the Google APIs console (there's so many) when I should be using the App SHA1 (I have now added both to the console).
  • [Optional] To use the keytool: If you know the command prompt, you know that you have to refer to each tool using their full path unless you add it to the PATH environment variable:

      This allows you to use keytool from any folder:
    1. Open a command prompt
    2. Type CD C:\Program Files\Java
    3. Determine your JDK folder dir jdk* and append the \bin. Note this for later.
    4. Right-click on the "Computer" icon/label (desktop / start menu)
    5. Select Properties
    6. Click on Change settings or Advanced system settings
    7. Select the Advanced tab
    8. Click on the Environment Variables... button
    9. Under "System variables" find the PATH variable and add the JDK bin folder you noted earlier: Add Java\jdk\bin to Path
    10. Click on OK and close the respective dialogs (note that setting the variable via the command prompt will NOT work!)

  • To get the Test SHA1 code: Creating a Google Maps project in Android Studio (v0.8.6 beta) "creates" a SHA1 along with the project name: something similar to: 5B:3D:C4:92:CA:D5:12:89:45:1D:E2:64:CF:C8:21:F8:04:38:F2:3E;com.example.myapp. By default this is the SHA1 of your computer but add it anyway to the Google APIs console for testing purposes. To get it again:

      Finding your computer's Certificate Fingerprint SHA1
    1. Open a command prompt
    2. Type CD C:\Program Files\Java
    3. Determine your JDK folder dir jdk*
    4. Change directory to the JDK folder cd jdk<press tab key here>
    5. Change to bin folder cd bin
    6. Type
      keytool -list -v -keystore c:/Users/<your_username>/.android/debug.keystore -alias androiddebugkey - storepass android -keypass android
      1.  keytool -list -v -keystore c:/Users/<your_username>/.android/debug.keystore -alias androiddebugkey - storepass android -keypass android 
      (replace <your_username> with your windows login)
    Should be something like:
    Getting your computers SHA1

  • To get the App SHA1 code: You have to add the correct SHA1 to the Google APIs console for release purposes. This is the SHA1 from the certificate (*.jks) you used to upload the APK to the Google Play Developer Console.

      Finding the Certificate Fingerprint SHA1 of an existing keystore
    1. Open a command prompt
    2. Type CD C:\Program Files\Java
    3. Determine your JDK folder dir jdk*
    4. Change directory to the JDK folder cd jdk<press tab key here>
    5. Change to bin folder cd bin
    6. Note the name of the JKS file you use to sign an uploaded app
    7. Type
      keytool -list -v -keystore "c:/Users/<your_username>/AndroidStudioProject/<your_jks_file.jks>
      1.  keytool -list -v -keystore "c:/Users/<your_username>/AndroidStudioProject/<your_jks_file.jks> 
      (replace <your_username> with your windows login and <your_jks_file.jks> with the JKS file you used)
    8. Enter the password for the key store and you should get something like the following (don't use this one but it will look like this):
      myexampleapp, 27-Oct-2014, PrivateKeyEntry,
      Certificate fingerprint (SHA1): B4:52:80:2B:A0:52:97:FC:6E:66:FF:61:1E:79:20:AD:4A:60:DA:FD
      1.  myexampleapp, 27-Oct-2014, PrivateKeyEntry, 
      2.  Certificate fingerprint (SHA1): B4:52:80:2B:A0:52:97:FC:6E:66:FF:61:1E:79:20:AD:4A:60:DA:FD 
    9. This tells me the alias is "myexampleapp" for this keystore and the SHA1 to add to google which would be:
      1.  B4:52:80:2B:A0:52:97:FC:6E:66:FF:61:1E:79:20:AD:4A:60:DA:FD;com.mydomain.myappname 

    * In the above, if you have specified the correct bin folder in your PATH environment variable, then you can use the keytool from any folder, skipping the initial steps of navigating to the JDK folder.

  • Changing a keystore password
    keytool -storepasswd  -new <new_password> -keystore <my_keystore.jks>
    1.  keytool -storepasswd  -new <new_password> -keystore <my_keystore.jks> 
    (replace <new_password> with your windows login and <my_keystore.jks> with your JKS file)

  • Changing a key password
    keytool -keypasswd -alias <my_alias> -new <new_password> -keystore <my_keystore.jks>
    1.  keytool -keypasswd -alias <my_alias> -new <new_password> -keystore <my_keystore.jks> 
    (replace <new_password> with your windows login, <my_keystore.jks> with your JKS file) and <my_alias> with the app alias.

The above solved it for me
I had registered my computer SHA1 with the Google API console instead of the app SHA1, but here are some red herrings I found when debugging this issue:
  • Download from the Play Store:
    The google maps api will apparently NOT work if you downloaded the APK from another location. This wasn't the issue, once I had the right SHA1 registered in the Google APIs console other users could download the file from my website and see the maps. I'm not saying it won't fix a problem for you, just that downloading from the Play store was unrelated to the above.

If you forget your key (like I did) and which keystore file you used, then you'll have probably tried this:
  • Upload the APK to the Google Play store using a different key
  • The Play store will tell you there's a mismatch on the SHA1 fingerprints used and will display both of them to you.
  • Using the keytool you can reverse engineer this and work out which certificates were used for which APK listed in the store.
Category: AndroidOS :: Article: 592

Credit where Credit is Due:

Feel free to copy, redistribute and share this information. All that we ask is that you attribute credit and possibly even a link back to this website as it really helps in our search engine rankings.

Disclaimer: The information on this website is provided without warranty and any content is merely the opinion of the author. Please try to test in development environments prior to adapting them to your production environments. The articles are written in good faith and, at the time of print, are working examples used in a commercial setting.

Thank you for visiting and, as always, we hope this website was of some use to you!

Kind Regards,

Joel Lipman

Related Articles

Joes Revolver Map

Joes Word Cloud


Badge - Certified Zoho Creator Associate
Badge - Certified Zoho Creator Associate

Donate & Support

If you like my content, and would like to support this sharing site, feel free to donate using a method below:

Donate to Joel Lipman via PayPal

Donate to Joel Lipman with Bitcoin - Valid till 8 May 2022 bc1qjtp4l4ra452wzvuk9a45yfj82zkahsyy2z379y
© 2023 Joel Lipman .com. All Rights Reserved.