Reputation: 327
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?
Upvotes: 1
Views: 3327
Reputation: 1
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;
}
}
});
Upvotes: 0
Reputation: 4779
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
Upvotes: 4
Reputation: 513
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):
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.
Upvotes: 2
Reputation: 5182
For me a permission was missing:
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
adding it fixed the problem
Upvotes: 2
Reputation: 2773
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?
Upvotes: 1