2

I know this has been asked and answered many times but despite following lots of solutions on here I still can't get past this error: Failed to load map. Could not contact Google servers

I've set "Google Maps Android API v2" and deleted then regenerated the debug.keystore before trying with a new key but no further forward.

Any ideas what I'm missing?

My activity_main.xml:

<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.SupportMapFragment"
    map:cameraTilt="45"
    map:cameraZoom="14"
/>

Manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.abelsoul.androidmapproject"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
    android:minSdkVersion="11"
    android:targetSdkVersion="17" />
<permission
android:name="com.abelsoul.androidmapproject.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="com.abelsoul.androidmapproject.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-feature
    android:glEsVersion="0x00020000"
    android:required="true"/>

<application        
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.abelsoul.androidmapproject.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.maps.v2.API_KEY"
android:value="xxxxxxxxxxxxxxxxxxxxxx" />        
</application>
</manifest>

MainActivity:

package com.abelsoul.androidmapproject;

import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.Menu;

public class MainActivity extends FragmentActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}
Emil Adz
  • 40,709
  • 36
  • 140
  • 187
Robert
  • 5,278
  • 43
  • 65
  • 115
  • all i can see is different from my code is i have xmlns:tools="http://schemas.android.com/tools" im not even sure if thats necesarry in your xml – JRowan May 08 '13 at 23:11
  • Thanks. I tried adding that but same result. – Robert May 08 '13 at 23:15
  • 2
    i had that error a couple times 1 time was because on the google play services console my package name was wrong with key, and another time because i checked google maps api v2 and not google maps android api v2, im not 100% but it may be a google play services console thing because i think your code looks fine, thats what the error was for me both times – JRowan May 08 '13 at 23:22
  • Have you referenced the Google Play Services library in your project? – zbr May 08 '13 at 23:25
  • im not sure if i left it in from maps v1 or if its a v2 thing, its still in my manifest though and its running fine on the market – JRowan May 08 '13 at 23:30
  • @JRowan No __ thing is needed. – zbr May 08 '13 at 23:34
  • @Zabri, thanks, hey maybe that was it, lets wait and find out :) – JRowan May 08 '13 at 23:37
  • @JRowan, no it not, it's a Google Map API V1 permission, and not needed in API V2. the code look fine. There must be something you are doing wrong with generating or registering you SHA1 key. – Emil Adz May 09 '13 at 01:42
  • @Zabri: Yes, GPS library imported and referenced. – Robert May 09 '13 at 18:17
  • if somebody still looking for an answer, check here - the same problem: http://stackoverflow.com/a/17947755/1891118 – Oleksii K. Jul 30 '13 at 13:08

1 Answers1

2

If you use WIFI instead of a 3G data plan, maybe you need add the permission to access wifi state, such as

< uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> 

into your manifest file. This line fixed my issue.

Robert
  • 5,278
  • 43
  • 65
  • 115
Zephyr
  • 6,123
  • 34
  • 33