34

Authorization failure. Please see https://developers.google.com/maps/documentation/android/start for how to correctly set up the map.

Ensure that the following correspond to what is in the API Console: Package Name: com.company.app, API Key: AIzaSyC***OsTeo, Certificate Fingerprint: 4E5285***6BF53ED3 Failed to contact Google servers. Another attempt will be made when connectivity is established.

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


I know there are more then enough questions about this subject. But I just can't seem to get the maps view to work. The result is an empty maps view (with zoom buttons).

What I've done:
- Downloaded / installed google-play-services
- Added google-play-services.jar to libs/
- Enabled Google Maps API v2 in code.google.com/apis/console
- Set up the correct permissions

This is how my manifest looks like:

<uses-feature
    android:glEsVersion="0x00020000"
    android:required="true" />

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<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" />

<permission
    android:name="com.company.app.permission.MAPS_RECEIVE"
    android:protectionLevel="signature" />

<uses-permission android:name="com.company.app.permission.MAPS_RECEIVE" />

<application ...>
    <meta-data
        android:name="com.google.android.maps.v2.API_KEY"
        android:value="AIzaSyC***OsTeo" />
</application>

Google APIs console api access looks like this:

Key for Android apps (with certificates)
API key:        AIzaSyC***OsTeo
Android apps:   4E:52:85:***6B:F5:3E:D3;com.company.app
Activated on:   Jun 18, 2013 11:07 PM
Activated by:   my@email.com – you

And some code (which I can't see why this would result in an authorization error):

FragmentManager fragmentManager = super.getSupportFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
SupportMapFragment fragment = new SupportMapFragment();
fragmentTransaction.replace(R.id.mapContainer, fragment);
fragmentTransaction.commit();

As you can see I get an error saying the package name, api key and certificate fingerprint do not correspond with the google servers. But like I'm writing above, those values do match...

basvk
  • 4,437
  • 3
  • 29
  • 49
  • 2
    Shouldn't you activate the `Google Maps Android API v2`? You may want to remove the app from the device/emulator, clean the project and reinstall it. – user Jun 19 '13 at 06:58
  • have you enabled google maps for android in the api console and how did you refer to the library project? – Raghunandan Jun 19 '13 at 06:59
  • @Luksprog: Damn, how obvious. Only enabled `Google Maps API v2` and not `Google Maps Android API v2`. Now it works perfectly. Thanks! (Could you paste your comment as an answer, so I can accept it?) – basvk Jun 19 '13 at 07:02

10 Answers10

84

Activate the Google Maps Android API v2 service in the Google API's console. Also, after making changes do a full reinstall of the app on the device/emulator.

user
  • 86,916
  • 18
  • 197
  • 190
  • 45
    The important thing to note is to make sure to do a clean install of the app on the device after rebuilding. – Robot Jul 12 '13 at 12:47
  • 3
    Thanks a lot @Robot ... I spent hours figuring this out and never thought the solution would be this easy! – Zeba Jul 22 '13 at 13:22
  • Thank alot... suffered and thought myself that api key had problem.. later found yours.. – arshad kr Oct 08 '13 at 09:06
  • 7
    This is the second time I ran into this issue and it is also second time I was baffled. When you think you have done everything... REMEMBER TO RE-INSTALL THE APPLICATION!!! – nana Oct 17 '13 at 23:29
  • I had to uninstall and reinstall several times in order for this to take effect. – IgorGanapolsky Nov 06 '13 at 16:31
  • 1
    This is a good point, most of the tutorials online teaches how to generate key but none of them specifies that you also have to enable this service (which is by default disabled without any notification) – Murtuza Kabul May 12 '14 at 14:52
15

For me help this, if simple: When you work from Android Studio you write your Google API key in file google_maps_api.xml but Android Studio show you only key file for (debug) version in Project Manager. You need place your key in

\app\src\release\res\values\google_maps_api.xml

file too (like you place in place your key in

\app\src\debug\res\values\google_maps_api.xml

)

Iefimenko Ievgen
  • 379
  • 1
  • 5
  • 12
9

When you set up your API key, the package name is the value of the package attribute on your manifest, not the application name.

This (com.foo):

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.foo"

Not this (com.foo.MyApplication):

<application
    android:name="com.foo.MyApplication"
Christopher Pickslay
  • 17,523
  • 6
  • 79
  • 92
5

I had the same problem, but had activated the right api. The problem was that I used the wrong keystore file when getting my SHA1. I used the release keystore, instead I needed to use:

keytool -list -v -keystore debug.keystore

on this file (mac osX location):

~/.android/debug.keystore

That gave me another sha1 that I entered in the google console, and now it works.

Skullbox
  • 441
  • 1
  • 6
  • 18
5

Please ensure your package name is typed correctly in google developer console/credentials/package name. It must be your application top package name eg. com.company.appname not com.company.appname.ui.activity.maps . I followed instructions from https://developers.google.com/maps/documentation/android/start but created Activity in nested package. Google webpage entered nested package name and I had this error.

rojarand2
  • 51
  • 1
  • 2
4

Make sure following things:

https://code.google.com/apis/console/?noredirect
Click on Services(Left side panel) -> Enable Google Maps Android API v2

To get your SHA1 key you can use: following command This command will generate keystore

keytool -genkey -v -keystore GoogleMapV2.keystore -alias GoogleMapV2 -keyalg RSA -    keysize 2048 -validity 10000

This command give SHA1 key and other information

keytool -list -v -keystore ~/path/to/GoogleMapV2.keystore -alias GoogleMapV2 -storepass any-password -keypass any-password i.e :

68:1C:74:24:7B:1F:9C:71:76:DD:69:4F:F2:8F

: Your Keys inside <application> </application> tag

<meta-data
            android:name="com.google.android.maps.v2.API_KEY"
            android:value="YOUR KEY" />
<meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />

Permission outside <application> </application> tag, on the top

<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" />
    <!--
     The following two permissions are not required to use
     Google Maps Android API v2, but are recommended.
    -->
    <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" />

NOTE: Don't run App using Eclipse or emulator, Run into real device by creating an apk not using eclipse else would take incorrect debug key.

VkJ

Vinod Joshi
  • 7,696
  • 1
  • 50
  • 51
2

I have no evidence of this apart from my observation, but it looks like it may take a few minutes before the API key is active once it is set up.

A little patience seemed to work for me!

Blueberry
  • 2,211
  • 3
  • 19
  • 33
2

To Make it clear . If The Map activity shows with no error while debugging your app on the android sdk but it show nothing and give this error when u install the apk :

07-02 03:18:36.467 25914-26028/? E/Google Maps Android API: Authorization failure. Please see https://developers.google.com/maps/documentation/android-api/start for how to correctly set up the map. 07-02 03:18:36.470 25914-26028/? E/Google Maps Android API: In the Google Developer Console (https://console.developers.google.com) Ensure that the "Google Maps Android API v2" is enabled. Ensure that the following Android Key exists: API Key: YOUR_KEY_HERE Android Application (;):

The solution will be : placing your key in : \app\src\release\res\values\google_maps_api.xml

as u diid in : \app\src\debug\res\values\google_maps_api.xml

as mentioned here

Essam Mahdy
  • 139
  • 1
  • 8
1

Check the package name that was automatically created if you chose the quick route for making the API key. Mine had .functions appended to the package name which seemed to be the problem. https://console.developers.google.com/apis/credentials/

Codelicious
  • 604
  • 10
  • 12
1

I got this answer from Google Map support team when I had risen a ticket with them after looking for solutions:

  1. Generate a release key, you can find details how to do it here Google Cloud Console
  2. Upload your app to Google Play (signed APK file).
  3. After the app has been submitted, select your app from Google Play Console.
  4. Go to Development Tools -> Release management -> App signing.
  5. Copy the SHA-1 certificate which Google Play has issued after uploading the app.
  6. Go to Google Console and select your project.
  7. Select your API key, restrict your key, and paste the SHA-1 after package name.
  8. Press Save.
Nimantha
  • 6,405
  • 6
  • 28
  • 69
sidibe
  • 51
  • 5