1

I am trying to implement Google map into my app. I have created the Google Map API Key and also turn on Google Maps Android API V2. But when i am trying to implement into my app i got the following error:

Failed to load map. Error contacting Google servers. This is probably an authentication issue (but could be due to network errors). I tried all the possible ways but still getting this error.

Here is my Mainfest File:

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

<permission
    android:name="com.example.NearbyPlaces.permission.MAPS_RECEIVE"
    android:protectionLevel="signature" />

<uses-permission android:name="com.example.NearbyPlaces.permission.MAPS_RECEIVE"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<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-permission android:name="android.permission.ACCESS_WIFI_STATE" />

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

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

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

    <meta-data
        android:name="com.google.android.maps.v2.API_KEY"
        android:value="AIzaSyBHWdCiHAkgu3hneAJBd44DEGXCG_fwDcU" />
    <activity
        android:name=".MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

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

        </intent-filter>
    </activity>
    <meta-data android:name="com.google.android.gms.version" 
        android:value="@integer/google_play_services_version">
    </meta-data> 
</application>

</manifest>

Here is my main.xml file

<fragment xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:map="http://schemas.android.com/apk/res-auto"
    android:id="@+id/the_map"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:name="com.google.android.gms.maps.MapFragment"
    map:cameraTilt="45"
    map:cameraZoom="14"
/>
nem035
  • 34,790
  • 6
  • 87
  • 99
Developer
  • 1,435
  • 2
  • 23
  • 48

2 Answers2

0

Looks like you don't have internet permissions?

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

More possible permissions you need are here: https://developers.google.com/maps/documentation/android/start#specify_permissions

alpinescrambler
  • 1,934
  • 16
  • 26
  • I think I didn't see them there before. Anyways, how about checking this SO Post: http://stackoverflow.com/questions/17667935/failed-to-load-map-error-contacting-google-servers-this-is-probably-an-authent – alpinescrambler Sep 23 '14 at 22:30
0

Try moving the meta-tag:

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

At the bottom of the application tag, after the com.google.android.gms.version tag

<application>
    <!-- 
        rest of your xml 
    -->     
    <meta-data android:name="com.google.android.gms.version" 
        android:value="@integer/google_play_services_version">
    </meta-data>  
    <meta-data
        android:name="com.google.android.maps.v2.API_KEY"
        android:value="AIzaSyBHWdCiHAkgu3hneAJBd44DEGXCG_fwDcU" />
</application>

Also, probably irrelevant but, you are missing the gps feature in your manifest:

<uses-feature
    android:name="android.hardware.location.gps"
    android:required="true" />

Another thing you can try is inside your main.xml change:

android:name="com.google.android.gms.maps.MapFragment"

To:

class="com.google.android.gms.maps.SupportMapFragment"
nem035
  • 34,790
  • 6
  • 87
  • 99
  • thanks but when i add meta-tag: to bottom of the application it crashed. – Developer Sep 23 '14 at 22:20
  • @ShwetaThakar look at my edit? Is this how you did it? If so, then I am not sure, in the apps I've used google maps, my manifest was identical to yours besides the changes I mentioned... either your API key is wrong or it is an error in the java code – nem035 Sep 23 '14 at 23:06