问题
After a lot of research to resolve my issue, I have to ask. Everything is set up but the map won't show. The error is:
08-16 20:31:49.473: E/Google Maps Android API(10864): Failed to load map. Error contacting Google servers. This is probably an authentication issue (but could be due to network errors).
I am running the Map on Debug mode (I've also tried by installing the .apk into the device and running it) and the same thing happens - no Map.
- I have checked Api key
Manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
... >
<permission
android:name="com.my_package_name.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<uses-permission android:name="com.my_package_name.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" />
<application
... >
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyCEH*************************" />
</application>
</manifest>
Activity
public class Home extends Activity {
static final LatLng HAMBURG = new LatLng(53.558, 9.927);
static final LatLng KIEL = new LatLng(53.551, 9.993);
private GoogleMap map;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.home);
map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
}
}
回答1:
It's an authentication issue, it's likely you haven't setup your API key correctly, using your SHA1 fingerprint.
Take a look at this
回答2:
Activate these Services in the Google Console:
- Google Maps Android API v2
Then, recreate the API key and the Maps should work - they did for me.
回答3:
Put this into your manifest.
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version"></meta-data>
Also check that the Consent Screen (on Google Developer Console Website > Settings) has your email address and product name.
来源:https://stackoverflow.com/questions/18280879/android-google-maps-api-v2-authentication-error