• 14

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191


File: /home/prodcxja/public_html/questions/application/views/question.php
Line: 191
Function: _error_handler

File: /home/prodcxja/public_html/questions/application/controllers/Questions.php
Line: 433
Function: view

File: /home/prodcxja/public_html/questions/index.php
Line: 315
Function: require_once

name Punditsdkoslkdosdkoskdo

Google maps v2: Authorization failure

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:

    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" />

    android:protectionLevel="signature" />

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

<application ...>
        android:value="AIzaSyC***OsTeo" />

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

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

      • 1
    • 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.
      • 2
    • @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?)

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.

  • 83
Reply Report
    • The important thing to note is to make sure to do a clean install of the app on the device after rebuilding.
    • Thanks a lot @Robot ... I spent hours figuring this out and never thought the solution would be this easy!
      • 2
    • 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!!!
    • 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)

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


file too (like you place in place your key in



  • 14
Reply Report

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"

Not this (com.foo.MyApplication):

  • 9
Reply Report

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


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

  • 5
Reply Report

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.

  • 5
Reply Report

Make sure following things:

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 :


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

            android:value="YOUR KEY" />
            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" />

        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.


  • 4
Reply Report

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!

  • 2
Reply Report

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

  • 2
Reply Report

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.
  • 1
Reply Report