1

I get this message in logCat when I attempt to load a supportMapFragment:

Failed to load map. Error contacting Google servers. This is probably an authentication     issue (but could be due to network errors). 

I believe my key is valid because it works on one phone (galaxy s), but does not work for an older phone (optimus v) and newer phone (galaxy s3). I have all necessary permissions in the manifest and my network connection is just fine, so not sure why it would work on one phone by not another. Any ideas?

user1200083
  • 317
  • 1
  • 5
  • 13

5 Answers5

4

If all your permission settings and API key in manifest are correct, then if you are getting failed to load map, it is probably because of some sort of caching of wrong values that were used earlier. In such case, please uninstall the app completely on the phone in which you are seeing this issue and then do a fresh install.

If you reinstall without uninstalling the app, then the error will persist. Another way to test this effect is that if you have a maps app that is working, then even if you make the API key wrong, the new app with the wrong key will continue to work unless you uninstall the app and freshly install the wrong app

Ram Koti
  • 2,203
  • 7
  • 26
  • 36
tony m
  • 4,769
  • 1
  • 21
  • 28
2

For me a permission was missing:

<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>

adding it fixed the problem

maephisto
  • 4,952
  • 11
  • 53
  • 73
2

In cases, described by tony earlier, where everything else is configured correctly but you still get this error, instead of uninstalling and installing you can simply clear application data.

I found steps that reliably reproduce this problem and solution (works for me):

  • Install release build, signed by your release cert with maps API key issued for you release cert. All works fine.
  • Replace by a debug build, but ``forget'' to change the maps API key from release to debug. Yes, this is wrong and not supposed to work, but this happens when switching builds. Easily solved you thought... Hah!
  • Fix the maps api key in the debug re-build by changing it to the maps API key issued for your debug cert. Re-install debug build with now correct debug maps api key. Expect the maps to work now, but they don't. The problem seems to be on the device itself.
  • Clear app data and same install shows tiles again!

EDIT

This problem may have been fixed in: https://code.google.com/p/gmaps-api-issues/issues/detail?id=6099 If so, it is still unclear to me in which version of the google-play-services API this fix is included.

AnyDev
  • 435
  • 5
  • 16
1

The device on which you are testing your application needs to have a logged in Google account. Do you have an active account on all your tested devices? Have the play services been installed on all of the devices?

André Diermann
  • 2,725
  • 23
  • 28
  • All devices are logged in to google accounts, though different accounts. Google play is installed on all of them. – user1200083 Jul 16 '13 at 14:38
  • They are also all running in debug mode. Not sure if I need different keys. The device it works on is logged in to the account where I registered the key. – user1200083 Jul 16 '13 at 14:41
  • What wonders me in your case is that it runs perfectly on one device but don't on two others! You registered the key for a certificate with which you sign your application (so it did not depend on the user who registered the key). I assume it's always either your debug or your release certificate. Or did you deployed different versions of the app to each device? – André Diermann Jul 16 '13 at 15:04
0

This issue also comes, if your project has issues of hostnameverifier. I am using the following solution:

HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() {
    @Override`enter code here`
    public boolean verify(String hostname, SSLSession arg1) {
        if (hostname.equalsIgnoreCase(arg1.getString("")) {
            return true;
        } else {
            return false;
        }
    }
 });  
Ram Koti
  • 2,203
  • 7
  • 26
  • 36