0

google maps does not load and gives a blank screen tried a few guides and tried google's guide but none seem to work this is all i have added, couldnt find a problem :-/

logcat:

06-27 01:21:16.470: I/Google Maps Android API(12628): Google Play services client version: 4452000
06-27 01:21:16.490: I/Google Maps Android API(12628): Google Play services package version: 4452036
06-27 01:21:16.790: D/dalvikvm(12628): GC_FOR_ALLOC freed 3003K, 16% free 17823K/21008K, paused 32ms, total 33ms
06-27 01:21:16.800: I/fpp(12628): Making Creator dynamically
06-27 01:21:16.800: I/Google Maps Android API(12628): Google Play services client version: 4452000
06-27 01:21:16.810: W/ActivityThread(12628): ClassLoader.loadClass: The class loader returned by Thread.getContextClassLoader() may fail for processes that host multiple applications. You should explicitly specify a context class loader. For example: Thread.setContextClassLoader(getClass().getClassLoader());
06-27 01:21:17.261: I/Google Maps Android API(12628): Failed to contact Google servers. Another attempt will be made when connectivity is established.
06-27 01:21:24.709: D/dalvikvm(12628): GC_FOR_ALLOC freed 3259K, 15% free 19643K/23084K, paused 40ms, total 40ms
06-27 01:21:32.367: E/Google Maps Android API(12628): Failed to load map. Error contacting Google servers. This is probably an authentication issue (but could be due to network errors).

android manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    android:versionName="1.0.0"
    android:versionCode="1"
    package="com.sahaab.android.muslimzone.test" >
    <uses-sdk android:minSdkVersion="11" android:targetSdkVersion="19" />

    <!-- The following two permissions are not required to use
     Google Maps Android API v2, but are recommended. -->
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

    <!-- Required OpenGL ES 2.0. for Maps V2 -->
    <uses-feature
        android:glEsVersion="0x00020000"
        android:required="true" />    

    <permission
            android:name="com.sahaab.android.muslimzone.test.permission.MAPS_RECEIVE"
            android:protectionLevel="signature"/>

    <uses-permission android:name="com.sahaab.android.muslimzone.test.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-feature
        android:name="android.hardware.location"
        android:required="false" />
    <uses-feature
        android:name="android.hardware.location.network"
        android:required="false" />
    <uses-feature android:name="android.hardware.location.gps" />
    <uses-feature
        android:name="android.hardware.wifi"
        android:required="false" />    

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />
        <meta-data
             android:name="com.google.android.maps.v2.API_KEY"
             android:value="AIzaSyDTkYW-kWs9VKB40pv7Qhw972blaz-GD1A" />

        <activity
            android:name="com.sahaab.muslimzone.activity.MainActivity"
            android:label="@string/app_name"
            android:launchMode="singleTop" >
            <meta-data android:name="android.support.PARENT_ACTIVITY" android:value=".activities.MyActivity" />
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>        

        <activity
            android:name="com.sahaab.muslimzone.activity.InfoActivity"
            android:label="@string/app_name"
            android:launchMode="singleTop" >
            <meta-data android:name="android.support.PARENT_ACTIVITY" android:value=".activities.MyActivity" />
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>              

        <activity
            android:name="com.sahaab.muslimzone.activity.IqamahActivity"
            android:label="@string/app_name"
            android:launchMode="singleTop" >
            <meta-data android:name="android.support.PARENT_ACTIVITY" android:value=".activities.MyActivity" />
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>          

    </application>

</manifest>

activity :

package com.sahaab.muslimzone.activity;

import com.sahaab.android.muslimzone.test.R;

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

public class IqamahActivity extends Activity {

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

layout :

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

2 Answers2

2

Update Your Code .I hope it helps you . It working for me !

package com.sahaab.muslimzone.activity;

import com.sahaab.android.muslimzone.test.R;

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

public class IqamahActivity extends FragmentActivity {

GoogleMap map;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_iqamah);
map =((SupportMapFragment)getSupportFragmentManager().findFragmentById(R.id.iqamah_map)).getMap();

    }
}

Change your XML

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

For,More information Please Visit Here

IntelliJ Amiya
  • 74,896
  • 15
  • 165
  • 198
  • @SimplePlan Sir : I have faced same problem . Then use it .Actually SupportMapFragment belongs to the v4 support library, contrary to the default MagFragment that is a native component in Android. – IntelliJ Amiya Jun 27 '14 at 06:06
  • 1
    @A Ya that's reason. but another reason is if your `minsdk<12` then you should used `SupportMapFrgament` for Backward compability Support and your activity should also extends `FragmentActivity` for that. – M D Jun 27 '14 at 07:19
  • @SimplePlan Yes yes .Glad to receive your information . – IntelliJ Amiya Jun 27 '14 at 07:23
1

Amiya is right, you need to use FragmentActivity to use Fragments.

To find out the difference between Activity and FragmentActivity, this might help!

if you're targeting API 12 and above, you can use MapFragment. Otherwise, use SupportMapFragment.

SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);

Click here to view more about Google Maps Android API v2.

Hope this helps!

Community
  • 1
  • 1
heychar
  • 93
  • 1
  • 9