问题
OK, I'm having the weirdest bug right now : the Android application I'm working on is displaying a grey background instead of the map, such as below :
(source: hostingpics.net)
Here's the logcat :
04-25 15:08:42.082: E/Google Maps Android API(19139): Failed to load map. Could not contact Google servers.
04-25 15:08:42.082: W/Google Maps Android API(19139): Please add <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> into AndroidManifest.xml to ensure correct behavior under poor connectivity conditions.
I have NO idea what might have caused this. I only changed a small part of my code that was completely unrelated to the map. And besides, I tried reverting the changes I made, and it still didn't work. I tried adding the line the logcat gave me, changing the API key, re-installing the Google Play library, deleting the previous versions of my app on my tablet, basically pretty much everything that I read on the Internet. Still doesn't work.
If anyone has any idea what the problem might be, that would be great.
回答1:
This problem is caused when there is a problem with your key or a problem with it's configuration in the Google API Console.
Go over this blog post I wrote on how to produce the key and integrate in in the console:
Google Maps API V2 key
if this is not helpful you can try to delete the dubug.keystore
folder in you user folder, compile
some project in eclipe (which result in regenerating this key) and try to register it again.
UPDATE: From the new error you posted, do you have this permission in your manifest file:
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
回答2:
Try this: set the “Custom debug keystore”
setting (empty by default
) to the same value as the “Default debug keystore”
in the Eclipse preferences.
回答3:
Emil's post above helped me, I was getting the same error and realised that this was due to me changing the name of my project. I added the changed name along with the same SHA1 I had for my old project on a new line (leaving the one with the old name above) in the console and it seemed to work as normal.
来源:https://stackoverflow.com/questions/16217418/android-google-maps-application-showing-grey-background-instead-of-the-map