31

I know this is a common question and usually the solution is to generate a separate key for release. I've done it several times and my API key in developers console contains two different SHA1-fingerprints: one for debug from AndroidStudio and on for release from my own keystore. I have signed the app with the same keystore and enabled Google Maps Android API v2 in the console. But still the maps activity shows just the white screen with 'Google' in the left bottom corner.

Are there any suggestions how to solve the problem?

4
  • so you got the google maps api key?? where did you put it?? if you are having difficulties then create a new maps activity, it will then show you the xml file where you need to put the key in, and then delete that activity.
    – Tasos
    Sep 12, 2015 at 23:24
  • @Tacos I put it in the in the automatically generated string-value in google_maps_api.xml that is put in the manifest file afterwards
    – mityakoval
    Sep 12, 2015 at 23:27
  • Ok, cool. do you see any errors in the log cat, regarding maps api key? if no errors, when you move your finger on the map, does the map magically appear. That happened to me before, cause my fragment layout was screwed.
    – Tasos
    Sep 12, 2015 at 23:29
  • It is happening due to you added debug SHA1 key on google, So please create SHA1 for release mode, fore more info Kindly have a look on this video How to create SHA1 for release youtu.be/g75cZXjmuj8 Feb 14, 2017 at 10:57

7 Answers 7

77

It sounds like you only have the API key entered in the debug google_maps_api.xml. Also, it sounds like you're using the same API key for debug and release, but you still need to enter it in the google_maps_api.xml under the release folder as well as the one in the debug folder.

It's a little confusing, because when the project is in Android view, you can only see the debug file (although it should have (debug) in parenthesis next to it in that view).

In order to modify the release version, switch to Project view by using the dropdown in the upper left of the Project Explorer. Then, expand app/src/, and you will see subfolders debug and release. Under there, you should see two separate google_maps_api.xml files under debug/res/values and release/res/values.

Make sure that the API key is populated in the google_maps_api.xml file under the release/res/values folder, since this is the one that will be used for the signed release apk.

enter image description here

10
  • 3
    Thank you a lot! That was the problem! I used Android view and didn't suspect there are two different folders for it. I wonder why isn't it mentioned anywhere. Anyway, thank you!
    – mityakoval
    Sep 12, 2015 at 23:58
  • 1
    @Daniel Nugent I have added api key in both values folders (debug &release) still map fragment is not showing. Nov 27, 2015 at 4:20
  • @payaltuteja do your logs show any errors related to the map? Nov 27, 2015 at 4:25
  • @payal you will need to look at the logs while running the release version. Nov 27, 2015 at 4:58
  • 1
    @Saleem Khan C H It was giving authorization failure. I have checked the logs.In releae apk logs sha1 was different as given at a time of debug mode on console and i have added that logs sha1 on google developer console and issue get resolved Jul 27, 2016 at 14:38
25

If you chose Google Play App Signing then your App's SHA-1 will be different one when it will be released.

Because Google remove your uploaded certificate and then sign the App with a new one,

So you have to know the new SHA-1 key.

(You don't have to follow the log for release and track the new SHA-1 generated)

enter image description here


You can compare the 2 SHA-1 keys.

Origin answer

6
  • I put the App Signing Certificate SHA1 as you shown above, but still the map is not visiable. Oct 5, 2017 at 7:24
  • This is the answer I was looking for after more than hour. Thanks!!
    – jbc25
    Mar 24, 2018 at 13:47
  • Thanks a lot. mean while we have to set two SHA1 in google clound console.
    – Vrajesh
    Apr 5, 2018 at 16:41
  • Welcome @Vrajesh
    – Wajih
    Apr 7, 2018 at 5:46
  • where to put this key? Jun 9, 2018 at 6:25
1

I solved it by looking at https://play.google.com/console in the left menu configuration then integrity of the app and copy the SHA1 of the upload key certificate that is below the SHA1 Certificate of the app signing key and add it in the same api key of https://console.cloud.google.com/. This way I didn't have to make changes to the apk.

If it doesn't work for you add both and try.

0

I did a lot of things to fix these but any solution not fix my problem to fix these issue I did these things

  1. Create signed apk with new keystore file make sure that the you will create that in release mode
  2. After creating the signed apk you should note the keystore path where you save your keystore file.
  3. You also need to use your google map API key with your release mode and debug mode both, you can use same API key with both but make sure that you should add two different sha keys for your single api key on google console.
  4. You should go to use the path of bin folder of java from c drive because keystore tool is inside bin folder so suppose your file is like C:\Program Files\Java\jdk1.8.0_11\bin so you should follow this path to your android studio terminal change the path to C:\Program Files\Java\jdk1.8.0_11\bin and then type this command:

    keytool -list -v -keystore "/Users/NT/Desktop/generalkey.jks"(adress of your keystore file)
    
  5. Now by doing these you will get the sha key copy that key

  6. Go to google console/credentials
  7. Now go to your api you will see edit option go to edit and past your sha key into it and save it .
  8. Run your code.
0

you are using a version of sha1. you need to again generate SHA1 using command prompt after making you apk signed.

Steps to regenerate SHA1 is go to cmd and give the command like below:

C:\Program Files\Java\jre1.8.0_91\bin>keytool -list -v -keystore 

"C:\Your key store path\keystores\android.jks"

1)go to your java in program file open java version like jre1.8.0

2)open bin folder and run command like above follwed by your key store path that you have generated when you generated the signed apk after running this command on cmd you need to provide password of signed app and your SHA1 will be gerarated.

3)copy the sha1 and paste into console.developer with your package name within your api key.

0

It's too late to answer but may be helpful for others if they phase the same issue.

If adding key in the release did not work then please check your SHA key in your jks file and add the same key in google play google api console

To get released SHA open your terminal and type

Asad-MacBook-Air:~ asad$ keytool -list -v -keystore /your/path/keystore.jks

and then check SHA, it should be the same as it is used in google api console.

0

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:

AIza...etc

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>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.