user1200083
user1200083

Reputation: 327

Android Google Maps V2 authentication error

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

Answers (5)

amrinder singh
amrinder singh

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

tony m
tony m

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

AnyDev
AnyDev

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):

  • 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.

Upvotes: 2

maephisto
maephisto

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

Andr&#233; Diermann
Andr&#233; Diermann

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

Related Questions