14

I'm trying to get a google map to display. I can see the background (light gray background, small tiles, Google logo in the lower left), so I know that I'm close. However, there is no actual map displayed. In the LogCat, I see this message repeating over and over:

05-14 13:28:17.926: W/System.err(27458): at android_maps_conflict_avoidance.com.google.googlenav.datarequest.DataRequestDispatcher$DispatcherServer.run(DataRequestDispatcher.java:1702)

I'm using Google maps api 2 with a tethered phone for testing that is running 2.3.4.

Anyone know what might be causing this? Thanks!

package com.example.maptest;
import android.os.Bundle;
import com.google.android.maps.MapActivity; 
import com.google.android.maps.MapController; 
import com.google.android.maps.MapView;

public class MyMapActivity extends MapActivity {   

  private MapView mapView;   
  private MapController mapController;

   @Override   public void onCreate(Bundle savedInstanceState) {
     super.onCreate(savedInstanceState);
     setContentView(R.layout.map_layout);
     mapView = (MapView)findViewById(R.id.map_view);
   }

   @Override   
   protected boolean isRouteDisplayed() {
     return false;   
   }

 }

AndroidManifest.xml

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

    <permission android:name="com.example.maptest.permission.MAPS_RECEIVE" android:protectionLevel="signature"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="com.example.maptest.permission.MAPS_RECEIVE"/>
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

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

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

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >

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

        <activity
            android:name="com.example.maptest.MyMapActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

        <activity
             android:name=".MainActivity" >
             </activity>

        <meta-data
            android:name="com.google.android.maps.v2.API_KEY"
            android:value="xxxxxxxxxxxxxxxxxxxx"/> 

    </application>

</manifest>
Kishan Viramgama
  • 893
  • 1
  • 11
  • 23
AndroidDev
  • 20,466
  • 42
  • 148
  • 239

12 Answers12

17

This problem is usually related to the map API key used to sign manifest. Take a look at this post and this one which describe the same error you are experiencing. In both cases it is because the API key they used was created with the wrong keystore. You need to make sure you use your debug keystore when you create an API key in the Google API console if you are going to be testing from eclipse.

Community
  • 1
  • 1
Rarw
  • 7,645
  • 3
  • 28
  • 46
  • 1
    Thanks. I was reusing another API key from a different project. I generated a new one for this project, which got rid of the errors in the LogCat. Still no map, though... – AndroidDev May 14 '13 at 20:32
4

Basically you are mixing deprecated Android API v1 with the new API v2.

The easiest way to migrate is to remove all v1 related code and start from scratch, following this link: https://developers.google.com/maps/documentation/android/start

MaciejGórski
  • 22,187
  • 7
  • 70
  • 94
  • I have no choice since this needs to run on 2.3.4 (API 10). v2 only runs on API 11, as I understand it. No? – AndroidDev May 14 '13 at 20:07
  • 2
    No. API v2 works from 2.2 (API 8). Additionally it requires OpenGL ES 2.0, but (unless you are developing for emerging markets) more than 99% devices has that. – MaciejGórski May 14 '13 at 20:10
  • Thanks. I've been through the documentation that you suggest previously, but no luck. There is this line from that documentation: "Please note that the code below is only useful for testing your settings in an application targeting Android API 12 or later", so I'm still stuck. I'll keep working on it. – AndroidDev May 14 '13 at 20:34
2

go to developper console enable maps api for your device and then copy your key and paste in values->google_maps_api.xml . It works Use Android key(auto created by google service) if on android devices

Vageesha Km
  • 89
  • 2
  • 4
2

After days of struggle, I found the issue. In my manifest I had the key value stored in an xml file and it didn't work. Now i have

<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="AIzxxxxxxxxxxxxxxxxxxxxxxxkey" />    and it works.

Just removed the xml file... Hope it helps!

Marius Razvan Varvarei
  • 1,331
  • 1
  • 17
  • 21
1

If you have several packages in your app beware when you create the API key you must use the package name that included in top of the android mainfest.xml file

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    **package="com.xxx.xxx"**
    android:versionCode="1"
    android:versionName="1.0" > 
noelyahan
  • 4,195
  • 1
  • 32
  • 27
1

well actually I had lived this problem and it makes me crazy. after I found the solution. very simple:

1- in your project, google_maps_api.xml just check the web link is for your package name, if your package name exist and correct. go to page and get the key

To get one, follow this link, follow the directions and press "Create" at the end:

https://console.developers.google.com/flows/enableapi?apiid=maps_android_backend&keyType=CLIENT_SIDE_ANDROID&r=...

2- just create new gooogle maps activity project get the SHA-1 code.

dont forget SHA-1 code is same in your other project but web link is uniqu for each your program

mehmet
  • 1,558
  • 5
  • 30
  • 41
0

I had the same problem. The problem was in my manifest file. Check if the google maps key you have stored IN STRING.xml and google maps key in google_maps_api.xml does not have same name.

Diya Bhat
  • 235
  • 3
  • 12
0

One most probable reason for this is you have not added API key in the project manifest file. Simplest way to fix this is go to the "google_maps_api.xml" file and copy the link in the file and paste it in the browser. Click on the create button in the link and copy the api key that is being generated after that and paste it in the AndroidManifest.xml in the place of "Your Api Key" which is inside the meta-data tag, compile the project this will fix the issue.

Samyak Upadhyay
  • 573
  • 1
  • 12
  • 24
0

May be this is because of the Google API key you have to make put google_maps_api.xml file in the values folder and paste the correct API key in it. and also you have to put this code in AndroidManifest.xml file

 <application>
 <meta-data
        android:name="com.google.android.geo.API_KEY"
        android:value="YOUR_API_KEY" />

 </application>
Pranav
  • 1
  • 2
0

If above all answers do not work at all .Then use another Emulator . It worked for me.

0

If you create the key using the link in google_maps_api.xml it sets the package name of the MapActivity and not the package name of the application (defined in manifest).

Make sure you have the same package name console.developers.google.com as in application manifest.

SohailAziz
  • 8,034
  • 6
  • 41
  • 43
0

It can happen because of your key has not restricted yet. after you created your API key, you should restrict the key. https://console.cloud.google.com/apis/credentials

Mafei
  • 3,063
  • 2
  • 15
  • 37