0

I have developed an android application which has a map fragment in it. I got the "map key" from "google developer console" by specifying my project's package name and other required details.

I generally test my application by connecting an actual device to my machine and everything works ok. But when i build an apk as a debug or release version and install the apk in the same/different device, it doesn't show the map at-all.

I use Android Studio for development and build process.

How do i fix this issue? I am definitely sure that its something to do with the key not being picked properly when i build the apk but i am not sure how to fix this issue!

Update 1:

I figured out the problem using all of your suggestion. The part which i missing was that i was generating a new keystore in Android studio using "Generate signed apk" so that my apk is signed with the new SHA-1 for the release but i was not telling google that it needs to consider my new SHA-1.

So i did the following

  1. I went on the terminal/command prompt, got the newly created SHA-1. I used the command "keytool -list -keystore my_key_store_name.jks -alias my_key_store_alias_name" . This displayed my SHA-1
  2. I copied the SHA-1 and went to google developer console and added the project's package name and the new SHA-1

After the above steps, my map is displayed properly. :)

Thanks everyone for helping me solve it.

user3807940
  • 841
  • 2
  • 8
  • 16
  • Possible duplicate of [Generating Google map Release API Key](http://stackoverflow.com/questions/10386770/generating-google-map-release-api-key) – Farhad Feb 20 '16 at 07:16

3 Answers3

0

While building your application and installing it directly from studio, studio will use the debug key.But while releasing the app, the apk has to be signed with release key instead of debug key.The Android SDK tools generate this release certificate when you do a release build.

So for generating the map key, if you are in development phase, you can use debug key to generate map key. But when you release the app, you have to obtain new map key using the release key and replace that in your manifest file.

Regarding signing your app, refer this link and this so

Community
  • 1
  • 1
viratpuar
  • 524
  • 1
  • 5
  • 22
0

When you run app without creating apk then it will take your debug keystore as a keystore and you have set that key on developer console.

When you create apk then that apk will get created using different keystore i.e your app keystore.

keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android

keytool -list -v -keystore kestore_location -alias kestore_alias_name -storepass android -keypass kestore_pasword

So has-key created using that keystore is not set on developer console.

You just need to create new hash-key using app kestore and add it on developer keystore.

Add two keys here

It will display map.

Beena
  • 2,334
  • 24
  • 50
  • I guess i am failing to understand something. I have done the following when i started the project 1. Went to developer console with my SHA-1 key and generated an key. 2. Replaced placeholder in my android_manifest file with the actual key generated above 3. Tested application by connecting the device to my machine and "Running" the main activity. And map works. Now after step 3 what should i do? I am really sorry if i didnt understand your answer properly. I am completely new to map stuff and am getting confused here! – user3807940 Feb 20 '16 at 07:54
  • Just create new hash key with above command using your release app keystore. Add in it on developer console. It will work. – Beena Feb 20 '16 at 13:02
0

I think there is problem with SHA. Please check once again for SHA. Follow these steps to find correct SHA and match with console SHA

In Android Studio: 1. on right side of window just click on Gradle 2. refresh 3. app---> task---->android--->signingReport 4. SHA will display on Console

the generated SHA add on google console. Happy Mapping

  • I did what you said. I compared the SHA1 which was displayed in my android studio to the one in developer console. They both match. But one other thing which i noticed in my android studio signingReport was it has config details for "variant:debug" but for release it displays "variant:release config:none". So i guess its missing the configs for release??? – user3807940 Feb 20 '16 at 07:34