Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Map not showing up in Android

1) It's showing empty map with grey color only with +(zoom in) and -(zoom out) buttons.

2) I extracted the SHA1 key from the debug.keystore and generated the MAP API V2 key in the console.

3) I pasted that key in the manifest file.

4) GOOGLE MAP API V2 switched ON

and i use my Nexus 7 for debugging(USB Debugging)

  • LogCat Message :

Failed to load map. Error contacting Google servers. This is probably an authentication issue (but could be due to network errors).

Please help if i went somewhere wrong in these files.

AndoidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
  <manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="metro.tailors"
   android:versionCode="1"
   android:versionName="1.0" >

   <uses-sdk android:minSdkVersion="10" android:targetSdkVersion="17" />
   <permission android:name="metro.tailors.permission.MAPS_RECEIVE"    android:protectionLevel="signature"/>
 <uses-permission android:name="metro.tailors.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="metro.tailors.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>
    <activity
        android:name="metro.tailors.FactorsActivity"
        android:label="@string/title_activity_factors" >
    </activity>
    <activity
        android:name="metro.tailors.LadiesCategoryActivity"
        android:label="@string/title_activity_ladies_category" >
    </activity>
    <activity
        android:name="metro.tailors.GentsCategoryActivity"
        android:label="@string/title_activity_gents_category" >
    </activity>
    <activity
        android:name="metro.tailors.MapActivity"
        android:label="@string/title_activity_map" >
    </activity>
    <meta-data
 android:name="com.google.android.maps.v2.API_KEY"
 android:value="AIzaSyA2pMJiaPfwlz2yKaRNMZHykQkY_******"/>

</application>
</manifest>

This the XML File of the MapActivity

        <?xml version="1.0" encoding="utf-8"?>
 <fragment xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/map"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:name="com.google.android.gms.maps.MapFragment"/>

MapActivity.java

        package metro.tailors;

        import android.os.Bundle;
        import android.app.Activity;

        public class MapActivity extends Activity {

            @Override
            protected void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                setContentView(R.layout.activity_map);
            }

        }
like image 360
Usual Suspect Avatar asked May 24 '13 14:05

Usual Suspect


People also ask

Why is Google Maps not displaying?

There are various reasons why this happens. It's possible the location accuracy option is disabled, you're using an older version of the app, or you don't have proper access to the internet. The Google Maps app itself may have issues, too. Cache files and other app data can sometimes cause various issues with the app.

How do I get Google Maps back on my phone?

On your Android phone or tablet, open the Settings app. Tap Apps & notifications. Locate the Google Maps app from your list of downloaded apps.

Where has my Google Maps icon gone?

Open Android settings → Application Manager → Google Play Store (or whichever store you used to download MAPS.ME, e.g. Samsung Apps) and do Force Stop, Clear Cache, Clear Data. Restart the device. Reinstall MAPS.ME.


1 Answers

4) GOOGLE MAP API V2 switched ON

You should turn on Google Maps for Android:

enter image description here

Fragment support start only from API > 11, So either change your manifest file to that or add android-support Library and use the SupportMapFragment object along side with FragmentActivity.

To download support library check the below link.

http://developer.android.com/tools/extras/support-library.html#Downloading

The doc states Use MapFragment class only if you are targeting API 12 and above. Otherwise, use SupportMapFragment.

https://developers.google.com/maps/documentation/android/reference/com/google/android/gms/maps/MapFragment.

like image 88
Emil Adz Avatar answered Oct 20 '22 02:10

Emil Adz