I'm trying to load a map with Google API V2, but i meet few errors that i don't understand..
I've these errors :
Could not find class 'gpr', referenced from method gps.a
Could not find class 'com.google.android.gms.location.internal.ParcelableGeofence', referenced from method glt.a
Failed to load map. Error contacting Google servers. This is probably an authentication issue (but could be due to network errors).
Here, it's my manifest (a part) :
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<uses-permission android:name="android.permission.ACCESS_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_GPS" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<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"/>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="#string/keyAndroid"/>
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
I forgot something ? I checked the SHA1 of my certificate, and there is no error with that.
Thx,
There is a difference between Debug and Release keys. You need to generate the specific SHA1 key for the developer console and for your specific use of the app.
DEBUG
When you want to see the map in debug, you will find the debug key here (eclipse)
Or in the folder
~/.android/debug.keystore
In Windows it is
C:\User\YourUser.android\debug.keystore
You need to generate the SHA1 key of that keystore and add it in the Developer Console in your Google Maps API v2 for Android
RELEASE
For release keys you will have to go trough these four steps:
You need to (taken from here Generating Google map Release API Key):
Create your own signing key that you will use for publishing, using Keytool : http://developer.android.com/guide/publishing/app-signing.html#cert
Get the MD5 fingerprint of your newly generated key : https://developers.google.com/maps/documentation/android/mapkey#getfingerprint
Submit the signature to this link to get your Google Maps key : https://developers.google.com/android/maps-api-signup?hl=fr
Export your application with your newly created key, in Eclipse : right click on your projet -> Android Tools -> Export signed application package.
Important thing to notice here, that you need to add the package name at the end of the SHA1 key. Like
AB:CD:EF...:08;com.yourpackage.yourapp
USING THE KEYS
Then when you got those two keys, you will have to update it always when you are either using debug or release. Don't mix them up, write a comment next to the key entry like
<!-- DEBUG KEY: 12345... -->
<!-- RELEASE KEY: 23456... ->
Related
I am trying to learn Android development & doing it the first time to do some hands-on to develop my ideas. I want to load the google map with the current location on the emulator.
Referred SE Questions: Failed to load map. Error contacting Google servers. This is probably an authentication issue
Initially, I faced the problem "won't run unless I update google play service in android studio"
The problem got resolved after changing:
compile 'com.google.android.gms:play-services:9.0+
I also corrected API_KEY by generating the API_KEY from the link given in code file. Now I am not getting that error but still not able to load the map on the emulator. These seem to be connection issue & I added the permission in manifest files as well. But the problem still persists. Kindly guide me & provide your valuable suggestions.
google_maps_api.xml
<resources>
<!--
TODO: Before you run your application, you need a Google Maps API key.
To get one, follow this link, follow the directions and press "Create" at the end:
https://console.developers.google.com/flows/enableapi?apiid=maps_android_backend&keyType=CLIENT_SIDE_ANDROID&r=6C:42:DD:0A:5D:D3:E4:5E:79:C9:04:81:3A:7A:70:17:25:37:97:96%3Bcom.example.kapilj3.meetmeapp
You can also add your credentials to an existing key, using this line:
6C:42:DD:0A:5D:D3:E4:5E:79:C9:04:81:3A:7A:70:17:25:37:97:96;com.example.kapilj3.meetmeapp
Alternatively, follow the directions here:
https://developers.google.com/maps/documentation/android/start#get-key
Once you have your key (it starts with "AIza"), replace the "google_maps_key"
string in this file.
-->
<string name="google_maps_key" templateMergeStrategy="preserve" translatable="false">AIza_MY_ACTUAL_KEY</string>
</resources>
AndroidManifest.xml
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<!-- Goolge API Key -->
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="#string/google_maps_key" />
add this code to your application manifiest
I have developed an android app for my company, where I have introduced a map in a fragment.
The app works fine on my phone, but when providing this app to other fellow workers, in their phones the map is not showing, it appears the focus buttons and the Google logo, but that's it, no map.
layout
<fragment
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp"
class="com.google.android.gms.maps.SupportMapFragment"/>
manifest
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<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"/>
<!-- 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"/>
...
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyArrfA3PQ9kVcwucUGZCoc9yMUC9wc2g_4"/>
Fragment
/*Try to obtain the map from the SupportMapFragment*/
mMap = ((SupportMapFragment) getActivity().getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
it's a debug key problem.
you must use a release key.
With version 2 API's you can use the same key for release and debug. In your google api's console edit your allowed android apps and on each line put your debug/release key, and then your app name. You can use multiple lines, then it will work with both keys.
In Google Developer API Console
Click on Create New Android key...
In cmd.exe/Terminal: keytool -list -v -keystore mystore.keystore
Password: android
Now enter SHA1 key;package name for debug and press enter
Enter SHA1 key;package name for release
Click on Create
Now use this API key your project
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="#string/common_map_api_key"/>
I am making an android app with google maps:-
My steps:-
Main activity extends Fragment activity
Made a copy of Google play services library and imported it to eclipse.Further added a reference of the library to the project.
Enabled the build target of the project to Google API's 4.4.2
Created a browser key on Google API console.
Created an SHA1 certificate for the app in eclipse using the keytool plugin(Also verifies the key using the traditional command prompt technique and both match).
Created an android Api key on Google API console using the SHA1 key obtained
Issue:- I get a blank map on the screen with the zoom in and zoom out buttons
Here is my code:-
activity_main.xml:-
<fragment
class="com.google.android.gms.maps.SupportMapFragment"
android:id="#+id/map"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/spr_place_type"
/>
AndroidManifest.xml :-
<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"/>
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<permission
android:name="com.strangeworld.locations.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<uses-library
android:name="com.google.android.maps"/>
<activity
android:name="com.strangeworld.locatorapp.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyD2LVShEdbQWWV4......"/>
<meta-data android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
</application>
Log cat:-
01-10 10:33:28.059: E/dalvikvm(2440): Could not find class 'maps.ae.i', referenced from method maps.af.al.a
01-10 10:33:30.039: E/GooglePlayServicesUtil(2440): The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.
01-10 10:33:32.909: E/Google Maps Android API(2440): Authorization failure. Please see https://developers.google.com/maps/documentation/android/start for how to correctly set up the map.
01-10 10:33:32.929: E/Google Maps Android API(2440): Ensure that the following correspond to what is in the API Console: Package Name: com.example.locations, API Key: AIzaSyAZhJllASbTnr......, Certificate Fingerprint: 83033D1ECACA2C88F9AA2.....
While generating the key do i need to spicify the whole package name i.e. com.abcdm.locatorapp or just com.abcdm
Yes you need to mention the package name in the google api console
SHA;complete packagename
Also try regenerating the key
The Google Play services resources were not found. Check your project configuration to ensure that the resources are included
You need to reference the google play servies properly. Check this
Importing google-play-service library showing a red X next to this reference android
Your keystore is not appropriate or package name mistake in google api console, recheck once.
Which type of keystore you are using? If you use debug key and published map looks blank. Use release key to publish.
Google Map Android API v2 can't display map in play store application
mention the entire package name with the key after semicolon ie. com.abcdm.locatorapp
This question already has answers here:
Failed to load map. Error contacting Google servers. This is probably an authentication issue
(25 answers)
Closed 8 years ago.
I have been trying to app a Google Map in my Android app using the v2 API for the past two days, with no success. All I get every time is a
Google Maps Android API(16603): Failed to load map. Error contacting Google servers. This is probably an authentication issue (but could be due to network errors).
I have followed Google's setup tutorial (https://developers.google.com/maps/documentation/android/start), tried multiple times with different projects in different workspaces, tried different Google accounts, gone through various answers and suggestions here in StackOverflow, but to no avail.
I am using Eclipse 4.2.2 with Android SDK Tools 22.01 and I have installed Google Play services (rev. 7), also I have imported google-play-services_lib into my workspace and added a reference to that to my android project.
Here is my code:
AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.googlemapdemo"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<permission
android:name="com.example.googlemapdemo.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="com.example.googlemapdemo.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" />
<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"/>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.googlemapdemo.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="my_api_key" />
</application>
</manifest>
activity_main.xml:
<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
android:id="#+id/the_map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.google.android.gms.maps.SupportMapFragment"
/>
MainActivity.java
package com.example.googlemapdemo;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.Menu;
public class MainActivity extends FragmentActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
Also I created an API Project on https://code.google.com/apis/console/ where I have enabled the Google Maps Android API v2 service. Then I obtained my SHA1 debug certificate fingerprint using
keytool -list -v -keystore "C:\Users\my_user_name\.android\debug.keystore" -alias androiddebugkey -storepass android -keypass android
and entered that and the package name in the API console, got the API key and put it in the manifest (where my_api_key is). This procedure I repeated a number of times, regenerating the key but with the same result.
Could anyone help with this or suggest anything else I could try? Any help will be greatly appreciated!
Simple.
If you are sure that the API key is right, and this error still comes up Logcat,
then try this:
Uninstall app from device.
Clean the project
And run on device again
The map should now display on the device....this worked for me .. cheers :)
Found it after all, after turning off WiFi on the device I was using. It seems that when debugging over WiFi you also need the
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
in the manifest. Don't know if it was just my case or it's a general thing, but I guess it should be in the documentation somewhere (it's not).
So if you are reading this and having similar problems try either disabling WiFi or adding the above permission alongside the others.
Make sure you follow the instructions carefully in the documentation found at:
https://developers.google.com/maps/documentation/android/start#obtain_a_google_maps_api_key
As of the new ADT you should see an error message in the logcat viewer which gives you explicit instructions such as where to go, what to enable and the details you need to paste into the android fingerprint and app details. See below;
A few Gochas;
Enable BOTH Google Maps Android API v2 AND Google Play Android Developer API in the developer console! This got me :)
Make sure you are using the correct keystore to find the SHA1 hash
(this can be found by going to
window->preferences->android->build and look for SHA1) This will differ from your production keystore! Otherwise you can use keytool -list -v -keystore YOURKEYSTORE.keystore -alias YOURALIAS to view the SHA1
Add your elements INSIDE your tags
Add your elements INSIDE the <.manifest> tag (above the tag)
This permission solved the problem
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="my_api_key" />
android:value="my_api_key" should be an actual key that you get from https://code.google.com/apis/console
I ran into the same problem and found that this set of permissions works.
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
I think it is the problem of your API Key.
Try the Android Sample project for maps(Google play service) from new project.
and add your API key into maps AndroidManifest.xml file.
If it is not working then it will be the problem of API Key.
Just spend a few frustrating hours with this exact same issue.
Was trying to run the mapdemo application from Google. Generated new keys etc still would not run.
Simple solution as detailed above was to delete the app from the tablet and run again for eclipse. Problem went away.
In Eclipse: Window, Preferences, Android, Build, SHA1 fingerprint from the debug keystore is the value you need (this matches the Google documented way using Keytool form the command line).
The answer for my similar issue is to add:
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
Make sure the "Google Maps Android API v2" is enabled,
under Google APIs console, Services (see screenshot below.
If it's not enabled, you will not get an error saying the service is disabled
although you entered the SHA1 key.
Screenshot
just to say, I was sure that I did everything well, but I finally noticed that the name of the package in the project was not the same as the one declared in the AndroidManifest.xml, so not the same as in Google APIs console.
Guess what, I changed it and... tadaa it worked !
So for who comes here, check that too !
My solution was use the correct file
in my case i used debug.keystore in C:\Users\.android for generate SH1 KEY
after try meny times, a found anoter file in C:\Users\\Downloads\adt-bundle-windows-x86_64\adt-bundle-windows\sdk.android an use it, for generate SH1 Key
and then copy 45:B5:E4:6F:36:AD:0A:98:94:B4:02:66:2B:12:17:F2:56:26:A0:E0 values the api key site
All Work again
Make sure you have apk signed with right key
http://developer.android.com/tools/publishing/app-signing.html
I have found new Solution that was my silly mistake.
May you have changed you application package name after Google Map Integration.
One SHA1 certificate fingerprint and package name (separated by a semicolon) per line.
Example:
45:B5:E4:6F:36:AD:0A:98:94:B4:02:66:2B:12:17:F2:56:26:A0:E0;com.example
Check Google API Console
I have solved this kind of problem, i hope people who find the same problem with me(hopefully nobody else ever do the same mistake) will find this helpful
my cause was i made a mistake when i created the project, the package name was wrong then i changed the package name of the project, this will produce 2 applications with same name but different package name. starting from here the maps didnt work anymore. then even if i changed the server side google api key, it still wont work.
solution:
try to uninstall both of apps first then clean the solution. and the map shows up again.
After spending several hours and following every tip on stackoverflow, I made it work trying one last thing.
I wanted my Map to display in another activity which I call mapActivity not the mainActivity. so when I created the sh1 key in google console api I typed package name for my mapActivity.
!!BUT it always needs to be the package name of the main activity even though you don't display the map there, so = packagename.appname from mainactivity
Make sure that you are using the debug certificate fingerprint and not a release fingerprint in the Google Developers Console. Instructions on finding your debug key can be found here.
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.
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" />
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.
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>
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.
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.
You might have enabled the wrong service "Google Maps Android API v2", not "Google Maps API v2"
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.
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).
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>
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.