
Question:
I have Developed an application that have Google Map functionality so i use new google play services library but when i launch Google map activity its showing map but blank so what is wrong with my code
my manifest file xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.apa"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="18" />
<permission
android:name="com.example.apa.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<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-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<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-library android:name="com.google.android.maps" />
<application
android:debuggable="false"
android:allowBackup="true"
android:icon="@drawable/app_icon"
android:label="@string/app_name"
android:theme="@style/Theme.AppCompat.Light">
<activity
android:name="***************"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="*****.*****.***.ViewOnMap"
android:label="@string/title_activity_view_on_map" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value=*********************************" />
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
</application>
layout file
<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/map"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
class="com.google.android.gms.maps.SupportMapFragment"
android:name="com.google.android.gms.maps.MapFragment" />
activity file
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_view_on_map);
Global.startAppAd.loadAd();
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
fm = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
}
LogCat error
Google Maps Android API﹕ Failed to load map. Error contacting Google servers. This is probably an authentication issue (but could be due to network errors).
Answer1:
<ol><li>Check your API key carefully</li>
<li>Check your SHA key
carefully</li>
<li>You should be connected to internet using WIFI before first time using Google map and wait 2-3 min till download map data etc. next time no need to connected with internet but if u want to search another location it must also be connected with internet using WIFI .</li>
</ol>
Answer2:By seeing the <strong>LogCat error Google Maps Android API﹕ Failed to load map. Error contacting Google servers. This is probably an authentication issue (but could be due to network errors).</strong>
it seams its problem with Authentication. and Code should have <strong>googleMap = fm.getMap();</strong>
// Getting reference to the SupportMapFragment of activity_main.xml
SupportMapFragment fm = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
// Getting GoogleMap object from the fragment
googleMap = fm.getMap();
Try to use this... And Double check SHA1 key
<strong>EDIT</strong> :
Check Phone Location settings also..
Answer3:Try these:
<ul><li><strong>Google Play Services:</strong>
You have to download the latest Google Play Services
<a href="http://www.androidfilehost.com/?fid=23501681358540606" rel="nofollow">com.android.vending-4.8.20.apk</a>.In that site if google play
services wasn't working means you can find a lot of sites in
internet named com.android.vending 4.8.20.apk
.
you can run the Google play Services by using the Command Prompt
adb install com.android.vending 4.8.20.apk
.
<strong>Note:</strong> You have to download the latest Google play services because year by year latest version will be updated in internet.
</li> </ul>