I got the SHA 1 certificate from the debug keystore .
Using that I generated the Google Map V2 Api key .
I extended Fragment Activity.
I used "com.google.android.gms.maps.SupportMapFragment" in my xml.
When I run this , it shows the following errors. "Failed to load map. Could not contact Google servers" Authorization failed.
Can anybody help me to recover from this issue.
Manifest
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.demomap"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8"
android:targetSdkVersion="15" />
<permission
android:name="com.example.demomap.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="com.example.demomap.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<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:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyDze1i1aL3O2H60NN1URt5g3tz5PA-JYUc"/>
<activity
android:name=".MainActivity"
android:label="@string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
xml code:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="@+id/header"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="@string/hello_world"
tools:context=".MainActivity" />
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_below="@id/header"
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.google.android.gms.maps.SupportMapFragment"/>
</RelativeLayout>
java code:
package com.example.demomap;
import com.google.android.gms.maps.SupportMapFragment;
import android.os.Bundle;
import android.app.Activity;
import android.support.v4.app.FragmentActivity;
import android.view.Menu;
public class MainActivity extends FragmentActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}
On Google Api Console you need to go to services tab and ON Google Map Android API v2 . have you done it ?
Failed to load map. Error contacting Google servers issue with android google maps api v2 if you are getting this message with release api key - it means it is in debug mode. So export your app from eclipse and install the app.
It turns out that Google Play Console is probably signing your uploaded app with its own certificate and creating another SHA1 fingerprint different to the one you use for enable your API Map. Use the one that you can find in your Google Play Console>Release Management>App Signing setting up that one in your Google Developer Console
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.