2

These are the steps I am following to generate my map key for android:

1-) I execute this command:

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

This command will have as an output something like this:

Alias name: androiddebugkey
Creation date: Mar 13, 2013
Entry type: PrivateKeyEntry
Certificate chain length: 1
Certificate[1]:
Owner: CN=Android Debug, O=Android, C=US
Issuer: CN=Android Debug, O=Android, C=US
Serial number: 51401a0b
Valid from: Wed Mar 13 02:17:47 EDT 2013 until: Fri Mar 06 01:17:47 EST 2043
Certificate fingerprints:
     MD5:  XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX
     SHA1: XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX
     Signature algorithm name: SHA1withRSA
     Version: 3

2-) After obtaining the SHA1, I copy it and then I open this link: https://code.google.com/apis/console/

I set on this feature:

enter image description here

3-) After that I generate a new key:

Where XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX (is the SHA1 obtained above) and edu.osu.cse5326.busstopapp is the single package of my project.

enter image description here

4-) Finally, I copy the map API Key generated:

enter image description here

5-) And I paste into one of my layouts:

<com.google.android.maps.MapView xmlns:android="http://schemas.android.com/apk/res/android"
                    android:id="@+id/mapViewBusStopLocation"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:clickable="true"
                    android:apiKey="the_api_key"

                />

6-) I load the map from the corresponding Activity.

7-) This is my manifest.xml file:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="edu.osu.cse5326.busstopapp"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.CAMERA" />

    <uses-feature android:name="android.hardware.camera" />
    <uses-feature android:name="android.hardware.camera.autofocus" />

    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

    <permission
        android:name="edu.osu.cse5326.permission.MAPS_RECEIVE"
        android:protectionLevel="signature" />

    <uses-feature
        android:glEsVersion="0x00020000"
        android:required="true" />

    <uses-sdk
        android:minSdkVersion="10"
        android:targetSdkVersion="10" />

    <application
        android:name="edu.osu.cse5326.busstopapp.AppState"
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >

        <uses-library android:name="com.google.android.maps" />

        <activity
            android:name="edu.osu.cse5326.busstopapp.LoginActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

      Many other activities
    </application>

</manifest>

THE PROBLEM is that I'm only seeing the grey area, without the map information.

This are the exception I'm getting when trying to run the project:

03-13 16:48:28.045: W/System.err(375): IOException processing: 26
03-13 16:48:28.045: W/System.err(375): java.io.IOException: Server returned: 3
03-13 16:48:28.045: W/System.err(375):  at android_maps_conflict_avoidance.com.google.googlenav.map.BaseTileRequest.readResponseData(BaseTileRequest.java:115)
03-13 16:48:28.045: W/System.err(375):  at android_maps_conflict_avoidance.com.google.googlenav.map.MapService$MapTileRequest.readResponseData(MapService.java:1473)
03-13 16:48:28.045: W/System.err(375):  at android_maps_conflict_avoidance.com.google.googlenav.datarequest.DataRequestDispatcher.processDataRequest(DataRequestDispatcher.java:1117)
03-13 16:48:28.055: W/System.err(375):  at android_maps_conflict_avoidance.com.google.googlenav.datarequest.DataRequestDispatcher.serviceRequests(DataRequestDispatcher.java:994)
03-13 16:48:28.055: W/System.err(375):  at android_maps_conflict_avoidance.com.google.googlenav.datarequest.DataRequestDispatcher$DispatcherServer.run(DataRequestDispatcher.java:1702)
03-13 16:48:28.055: W/System.err(375):  at java.lang.Thread.run(Thread.java:1019)
03-13 16:48:28.365: W/System.err(375): IOException processing: 26
03-13 16:48:28.365: W/System.err(375): java.io.IOException: Server returned: 3
03-13 16:48:28.365: W/System.err(375):  at android_maps_conflict_avoidance.com.google.googlenav.map.BaseTileRequest.readResponseData(BaseTileRequest.java:115)
03-13 16:48:28.375: W/System.err(375):  at android_maps_conflict_avoidance.com.google.googlenav.map.MapService$MapTileRequest.readResponseData(MapService.java:1473)

I have been reading a lot and I think this is a problem with the Map API Key, but I can't find what I am doing wrong.

Things I have tried and didn't work:

  1. Delete the debug.keystore and generate all over again.
  2. I have try to run on a real devide, instead of the emulator.
  3. Regenerate the map api key and wait a couple of hours to see if it takes time to work.
Cacho Santa
  • 6,846
  • 6
  • 41
  • 73

2 Answers2

4

I don't get it, you are using the Google Map API V2 in all of your settings including the key you are getting from the console, but you are using the MapView object which is a Google Map API V1 object.

You should use the MapFragment or the SupportMapFragment object with the android-support-v4 library, depending on the minSDK you are writing your application for.

Here is a blog post I wrote on how to add a Google Map API V2 to your application, I think you will find it handy:

Google Map API V2

Emil Adz
  • 40,709
  • 36
  • 140
  • 187
  • hi, i want to show map location inside recyclerview cell, can u give some some advices? Which better: mapview or mapFragment? – famfamfam Dec 28 '21 at 15:53
  • @famfamfam, Hey. From my understanding you will use MapView today if you need to place it inside a fragment. If you don't have a base fragment then use a MapFragment instead. – Emil Adz Jan 11 '22 at 10:26
1

I searched a bit and found this question, and this answer:

When using the signed API key, the MapView will show up ONLY when the app is installed from the Android Market. So, installing the app from Eclipse (Run As, Debug As, etc) or command line (adb install) won't show the MapView. Rest assured, once the app is in the Market - you download it and the MapView will show up.

This is a bit weird, but I hope it will help you.

Community
  • 1
  • 1
abbath
  • 2,444
  • 4
  • 28
  • 40
  • I think that is only the case for the "production" key, I'm only trying to install a debug-key to start developing an application..... – Cacho Santa Mar 13 '13 at 23:20
  • You are using the old `com.google.android.maps.MapView` instead of `com.google.android.gms.maps.MapView`. can that be a problem? – abbath Mar 13 '13 at 23:34