0

is there a way to find out if i've generated a right API key ?

from the same debug.keystore i've managed to get Facebook HASH Key with no problems but from some reason after generating the MD5 fingerprint and generated an API key from Google my map is still blank.. which mean i can only see grids in it with no map..

my internet connection is on, and i have no error in my LogCat.. is there some kind of debugging i can do in order to check whether my API key is correct or not ?

XML:

<?xml version="1.0" encoding="utf-8"?>
<com.google.android.maps.MapView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/map"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:clickable="true"
    android:apiKey="my_generated_key"/>

UPDATE: when running a new Test application it works great with my api key. when i'm trying to embedded the map inside my application (inside a tab host) i get only grid view.

Asaf Nevo
  • 11,338
  • 23
  • 79
  • 154

3 Answers3

1

You should add in your XML like this:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <com.google.android.maps.MapView
          android:id="@+id/mapView"
                 android:layout_width="fill_parent"
                 android:layout_height="fill_parent"
                 android:enabled="true"
                 android:clickable="true"
                 android:apiKey="api key" />

</RelativeLayout>

if you don't have a layout, you are not able to see the map.

androidEnthusiast
  • 1,140
  • 1
  • 12
  • 21
  • But i see the map layout. but no map is loaded.. how come googles "Hello Maps" use map as root layout?? – Asaf Nevo Sep 07 '12 at 07:05
  • In "Hello Maps" is written that you open your layout/main.xml (in every you already have layout) and add a single MAPVIEW (means that you can't have more than one mapview) as the root NODE (A node can be an element node, an attribute node, a text node,...). Node is and it must stand in layout. In "Hello Maps", nowhere is written that you should use this note as a layout, just add it to your layout. – androidEnthusiast Sep 07 '12 at 08:23
  • i do understand what it says a bit different but i will give it a try and update here – Asaf Nevo Sep 07 '12 at 20:28
  • Did you try it? Look at this if you still have trouble: http://mobiforge.com/developing/story/using-google-maps-android – androidEnthusiast Sep 08 '12 at 08:10
  • yep i've tried it.. still not working... i'm starting to freak out.. there are only 2 thing need to be done in order to run the map. INTERNET permission and API key.. i've done both of them and yet my map is not loading! – Asaf Nevo Sep 08 '12 at 12:26
  • And you add this line to your manifest too? That is very strange... I have a lot of apps using Maps library and never had this kind of problem. I suggest you to make a new Android project and try again all with that key. If you again have gray grid, try to get a new key from Google again. – androidEnthusiast Sep 08 '12 at 16:11
  • i've found the problem.. because my map was inside a tabhost and the tabhost didn't extends MapActivity the map wasn't able to initilize.. found an answer to my question here http://stackoverflow.com/questions/12331063/android-google-map-doesnt-load-inside-tabhost – Asaf Nevo Sep 08 '12 at 17:28
0

Make sure you got INTERNET permission set and that your key is really MD5. Newer version of keytool returns SHA1 key instead of MD5. To get MD5 add -v to keytool options

Lord_JABA
  • 2,545
  • 7
  • 31
  • 58
0

If you have a gray background in your project, make sure that you have permission INTERNET in your Manifest, just before application tag. If you getting gray background on your device, make sure that you have created a new Api key with new MD5 for your application, based on your created application.keystore, which you created when you exported your app.

If you haven't done that, see this link for better explanation: One Google Maps key for all developers?

If your LogCat is fine, and you don't even have red "Couldn't get connection factory client" your map key is fine. :) But even if you had this error in LogCat, that doesn't mean anything, because it could represent some bug in Eclipse and your map will still working, no matter that, in emulator and on real device.

Community
  • 1
  • 1
androidEnthusiast
  • 1,140
  • 1
  • 12
  • 21