Google Maps API V2 'Failed to Load Map. Could not contact Google Servers'
Asked Answered
M

10

24

I have checked and double checked my APIkey that I registered on the Google Console however I am still getting the following error:

12-05 16:31:12.940: E/Google Maps Android API(12334): Failed to load map.  Could not contact Google servers.

What I am seeing is the zoom in/out buttons and the background for the MapView but no Map???!!!

Any ideas???

Answer

I will post it here because what solved my issue was stated in the comments of the accepted answer below.

It was the READ_GSERVICES permission. For some reason the permission wasn't mentioned on the developer site when it came to using them.

Mitinger answered 5/12, 2012 at 16:37 Comment(0)
A
48

For setting up Google Maps API v2 on Android, make sure that you have completed all of the following steps.

App Key For API Access

When Google asks for the SHA1 fingerprint of your app certificate, you will want most likely want to run this twice, once for your debuging certificate, and once for your publishing certificate.

keytool -list -v -keystore publishcert.keystore
keytool -list -v -keystore ~/.android/debug.keystore

The fingerprint of the app on the market is different then the fingerprint of an app that you are just testing!

Enable the service on the Google API Console

Login to the Google API Console.
On the services page, find Google Maps Android API v2.

Note - Google Maps API v2 is DIFFERENT then Google Maps Android API v2

In the API Access tab, click Create new Android Key

Add your certificate signatures for access to the APIs.

yourrelease-fingerprint;com.example.project.package
yourdebug-fingerprint;com.example.project.package

You will be provided with a generated API Access Key.

You may need to first create an API Project in the API Console

Amend the App Manifest

Add your API Key, inside of the <application> element.

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

Add the following permissions:

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

<uses-permission android:name="com.example.project.package.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"/>

Add the following feature request:

<uses-feature
    android:glEsVersion="0x00020000"
    android:required="true" />
Anastomosis answered 5/12, 2012 at 16:39 Comment(9)
Definitely signed it with my debugging key located User/.android/debug.keystoreMitinger
Have you enabled the use of the Maps API in your Google API Console?Anastomosis
Yep on services bit I have switched it to on and accepted the terms & conditions.Mitinger
Setup INTERNET and READ_GSERVICES permissions in the manifest?Anastomosis
Just as you posted it I had done it. It was the READ_GSERVICES permission. Following the permission on the developer site that wasn't there? Thanks for your helpMitinger
Not a problem! Glad you found your solution!Anastomosis
Thanks. I have now added READ_GSERVICES and my code is now working!Serotonin
Thank you! After hours of debugging, you made me realized that I choose Google map instead of Google map android...Mystic
Jesus.. activating the android api did the tick.. well a simple click with the cost of a few hours.. thank's!Achelous
C
18

Make sure all below mentioned points are taken care:

1) Wrong service was enabled. Make sure the "Google Maps Android API v2", not "Google Maps API v2" is enabled and re-generate the API key.

2) Add the following elements to your manifest. Replace com.example.mapdemo with the package name of your application.

3) Use of correct certificate and key. Release certificate, which WILL NOT WORK during debugging when you run the app on my phone. You have to use the debugging keystore certificate fingerprint instead.

Carltoncarly answered 23/4, 2013 at 10:56 Comment(4)
FUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU. Okay, missed the google maps android api v2, i'm an idiot. Thank youDerm
"Google Maps Android API v2", not "Google Maps API v2" <<< my carelessParker
Wasted half of my day due to this sillinessSackey
HAHA, same problem here, I added Google Maps API v2, dammit that was the wrong one. Four hours I will not get back. Thanks!!!Hoodoo
K
7

It could be an issue with the Manifest. The following works for me, specifically permission.MAPS_RECEIVE solved a similar issue I had: zoom buttons and myLocation displayed, but map had no tiles...

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.discos2.example"
    android:versionCode="1"
    android:versionName="1.0" >

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

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

    <uses-permission android:name="com.discos2.example.permission.MAPS_RECEIVE" />

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />

    <uses-feature
        android:name="android.hardware.location"
        android:required="false" />
    <uses-feature
        android:name="android.hardware.location.network"
        android:required="false" />
    <uses-feature android:name="android.hardware.location.gps" />
    <uses-feature
        android:name="android.hardware.wifi"
        android:required="false" />
    <uses-feature
        android:glEsVersion="0x00020000"
        android:required="true" />

    <application
        android:hardwareAccelerated="true">
        <meta-data
            android:name="com.google.android.maps.v2.API_KEY"
            android:value="__NEW_GOOGLE_MAPS_V2_KEY_GOES_HERE__" />

        <activity
            android:name=".ui.activities.MainActivity" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

    </application>

</manifest>
Karalee answered 5/12, 2012 at 17:1 Comment(1)
Thanks for posting the permission I was missing was the READ_GSERVICESMitinger
C
4

BTW, I'm running Windows 7. I fussed over this for days, until I discovered the following: I have more than one debug.keystore. One is at:

C:\android-sdk\.android\debug.keystore

And there's another, at:

C:\Users\David\.android\debug.keystore

Once I found the "C:\Users\David.android\debug.keystore" I did:

keytool -list -alias androiddebugkey -keystore C:\Users\David\.android\debug.keystore -storepass   android -keypass android -v

I submitted the resulting SHA1 to google console and got an API-key that works. Getting the SHA1 from the keystore at "C:\android-sdk.android\debug.keystore" does not work.

Consignee answered 31/3, 2013 at 16:24 Comment(0)
K
1

I was facing the same issue ; but for me it was keystore issue I was signing it with debug keystore hence Google map api v2 was not able to connect to Google map.

I created a new api key using my-release-keystore.keystore (u can find it at C:\Users\{YOUR_USER_NAME}\.android\my-release-key.keystore) generate SHA1 using keytool available in JDK; copy it and register with google console.

Use api key generated in your applications manifest file. Sign it with my-release-key.keystore will pushing it on device.

Kellene answered 28/1, 2013 at 9:21 Comment(0)
R
1

You might have enabled the wrong service "Google Maps Android API v2", not "Google Maps API v2"

Ripley answered 3/5, 2013 at 0:12 Comment(0)
S
0

I had the same problem. I just simply missed this point: When you list your Google APIs services, there are three Google Maps API available.

Google Maps Android API v2
Google Maps API v2
Google Maps API v3 ...

Check that you have Android version (Google Maps Android API v2) enabled, when you code for Android. Google Maps API v2 was not good enough.

Sterner answered 23/4, 2013 at 15:34 Comment(0)
D
0

Just create new API key with SHA and most importantly correct package name (like com.example.mapdemo). Use the new generated key in your AndroidManifest.xml.

I guess we need new API key for all new eclipse projects which uses Google maps (as creating new key also requires the package name, which is essentially different for all projects).

Droopy answered 23/4, 2013 at 23:3 Comment(0)
M
0

After spending many hours, the problem had been eventually solved:

if none of the above helped you solving your problem, try to put your api key into values/strings.xml

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

<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="map_key">YOUR_KEY</string>
</resources>
Marmalade answered 16/7, 2013 at 11:25 Comment(0)
P
0

I did everything what was required to achieve this task. My key, manifest, code etc. were all right. But, in the end after wasting a lot of time, the debug keystore which I was using was the wrong one. It's was all about the SHA1 fingerprint after all.

Postpositive answered 10/5, 2015 at 6:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.