title: Changing to a Fragment Activity crashes application - Android
body: <p>I am making an Android Application with four Tabs. One of the Tabs is a 'Find Us' tab which should show Google maps with two locations, The User's current position and a Marker.</p>
  
  <p>I already have my main activity which uses a tabhost to generate four tabs, one of which is find us: </p>
  
  <pre><code>import android.app.TabActivity;
  import android.content.Intent;
  import android.graphics.drawable.Drawable;
  import android.os.Bundle;
  import android.view.View;
  import android.widget.ImageView;
  import android.widget.TabHost;
  import android.widget.TabHost.TabSpec;
  import android.support.v4.app.FragmentActivity;
  
  public class AndroidTabLayoutActivity extends TabActivity {
  /** Called when the activity is first created. */
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      TabHost tabHost = getTabHost();
  
      // Tab for About
      TabSpec photospec = tabHost.newTabSpec("About");
      // setting Title and Icon for the Tab
      photospec.setIndicator("About", getResources().getDrawable(R.drawable.icon_about_tab));
      Intent photosIntent = new Intent(this, AboutActivity.class);
      photospec.setContent(photosIntent);
  
      // Tab for Facebook
      TabSpec songspec = tabHost.newTabSpec("Facebook");        
      songspec.setIndicator("Facebook", getResources().getDrawable(R.drawable.icon_facebook_tab));
      Intent songsIntent = new Intent(this, FacebookActivity.class);
      songspec.setContent(songsIntent);
  
      // Tab for Videos
      TabSpec videospec = tabHost.newTabSpec("Notices");
      videospec.setIndicator("Notices", getResources().getDrawable(R.drawable.icon_youtube_tab));
      Intent videosIntent = new Intent(this, YoutubeActivity.class);
      videospec.setContent(videosIntent);
  
   // Tab for Map
      TabSpec mapspec = tabHost.newTabSpec("Find Us");
      mapspec.setIndicator("Find Us", getResources().getDrawable(R.drawable.icon_map_tab));
      Intent mapIntent = new Intent(this, MapsActivity.class);
      mapspec.setContent(mapIntent);
  
      // Adding all TabSpec to TabHost
      tabHost.addTab(photospec); // Adding about tab
      tabHost.addTab(songspec); // Adding facebook tab
      tabHost.addTab(videospec); // Adding videos tab
      tabHost.addTab(mapspec); // Adding map tab
  } 
    //making the tab view:
      private View makeTabIndicator(Drawable drawable){
      ImageView Tabimage = new ImageView(this);
      Tabimage.setImageDrawable(drawable);
      Tabimage.setBackgroundResource(R.drawable.icon_about_tab);
      return Tabimage;
  
  }}
  </code></pre>
  
  <p>I have followed the guidance at developers.google.com/maps/documentation/android/map therefore the map class looks like this:</p>
  
  <pre><code>import android.app.Activity;
  import android.os.Bundle;
  import android.support.v4.app.FragmentActivity;
  
  public class MapsActivity extends Activity {
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
          setContentView(R.layout.map);}}
  </code></pre>
  
  <p>And my map.xml looks like this:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:orientation="vertical" &gt;
  &lt;fragment
  android:id="@+id/map"
  android:name="com.google.android.gms.maps.MapFragment"
  android:layout_width="match_parent"
  android:layout_height="match_parent" /&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>At the moment, that works fine and displays a map, however, to display makers on it, you need to add an overlay. For that, instead of <code>public class MapsActivity extends Activity {</code> it should say <code>public class MapsActivity extends FragmentActivity {</code> Because it is not a FragmentActivity, code like below won't work:</p>
  
  <pre><code>private GoogleMap mMap;
  mMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
  mMap.addMarker(new MarkerOptions()
          .position(new LatLng(0, 0))
          .title("Hello world"));
  </code></pre>
  
  <p>When I do change it to <code>FragmentActivity</code> the application crashes, logcat below:</p>
  
  <pre><code>06-27 12:05:11.550: D/dalvikvm(2567): GC_FOR_ALLOC freed 71K, 13% free 9516K/10887K, paused 21ms, total 22ms
  06-27 12:05:11.560: I/dalvikvm-heap(2567): Grow heap (frag case) to 12.903MB for 2457616-byte allocation
  06-27 12:05:11.590: D/dalvikvm(2567): GC_CONCURRENT freed 6K, 11% free 11910K/13319K, paused 12ms+2ms, total 38ms
  06-27 12:05:11.991: D/libEGL(2567): loaded /system/lib/egl/libEGL_mali.so
  06-27 12:05:12.041: D/libEGL(2567): loaded /system/lib/egl/libGLESv1_CM_mali.so
  06-27 12:05:12.051: D/libEGL(2567): loaded /system/lib/egl/libGLESv2_mali.so
  06-27 12:05:12.121: D/OpenGLRenderer(2567): Enabling debug mode 0
  06-27 12:05:17.526: W/IInputConnectionWrapper(2567): showStatusIcon on inactive InputConnection
  06-27 12:05:54.812: D/AndroidRuntime(2567): Shutting down VM
  06-27 12:05:54.812: W/dalvikvm(2567): threadid=1: thread exiting with uncaught exception (group=0x412552a0)
  06-27 12:05:54.952: E/AndroidRuntime(2567): FATAL EXCEPTION: main
  06-27 12:05:54.952: E/AndroidRuntime(2567): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.asa.ignite/com.asa.ignite.MapsActivity}: android.view.InflateException: Binary XML file line #8: Error inflating class fragment
  06-27 12:05:54.952: E/AndroidRuntime(2567):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2081)
  06-27 12:05:54.952: E/AndroidRuntime(2567):     at android.app.ActivityThread.startActivityNow(ActivityThread.java:1922)
  06-27 12:05:54.952: E/AndroidRuntime(2567):     at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:135)
  06-27 12:05:54.952: E/AndroidRuntime(2567):     at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:347)
  06-27 12:05:54.952: E/AndroidRuntime(2567):     at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:704)
  06-27 12:05:54.952: E/AndroidRuntime(2567):     at android.widget.TabHost.setCurrentTab(TabHost.java:368)
  06-27 12:05:54.952: E/AndroidRuntime(2567):     at android.widget.TabHost$2.onTabSelectionChanged(TabHost.java:150)
  06-27 12:05:54.952: E/AndroidRuntime(2567):     at android.widget.TabWidget$TabClickListener.onClick(TabWidget.java:546)
  06-27 12:05:54.952: E/AndroidRuntime(2567):     at android.view.View.performClick(View.java:4162)
  06-27 12:05:54.952: E/AndroidRuntime(2567):     at android.view.View$PerformClick.run(View.java:17082)
  06-27 12:05:54.952: E/AndroidRuntime(2567):     at android.os.Handler.handleCallback(Handler.java:615)
  06-27 12:05:54.952: E/AndroidRuntime(2567):     at android.os.Handler.dispatchMessage(Handler.java:92)
  06-27 12:05:54.952: E/AndroidRuntime(2567):     at android.os.Looper.loop(Looper.java:137)
  06-27 12:05:54.952: E/AndroidRuntime(2567):     at android.app.ActivityThread.main(ActivityThread.java:4856)
  06-27 12:05:54.952: E/AndroidRuntime(2567):     at java.lang.reflect.Method.invokeNative(Native Method)
  06-27 12:05:54.952: E/AndroidRuntime(2567):     at java.lang.reflect.Method.invoke(Method.java:511)
  06-27 12:05:54.952: E/AndroidRuntime(2567):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1007)
  06-27 12:05:54.952: E/AndroidRuntime(2567):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:774)
  06-27 12:05:54.952: E/AndroidRuntime(2567):     at dalvik.system.NativeStart.main(Native Method)
  06-27 12:05:54.952: E/AndroidRuntime(2567): Caused by: android.view.InflateException: Binary XML file line #8: Error inflating class fragment
  06-27 12:05:54.952: E/AndroidRuntime(2567):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
  06-27 12:05:54.952: E/AndroidRuntime(2567):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
  06-27 12:05:54.952: E/AndroidRuntime(2567):     at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
  06-27 12:05:54.952: E/AndroidRuntime(2567):     at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
  06-27 12:05:54.952: E/AndroidRuntime(2567):     at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
  06-27 12:05:54.952: E/AndroidRuntime(2567):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:316)
  06-27 12:05:54.952: E/AndroidRuntime(2567):     at android.app.Activity.setContentView(Activity.java:1901)
  06-27 12:05:54.952: E/AndroidRuntime(2567):     at com.asa.ignite.MapsActivity.onCreate(MapsActivity.java:11)
  06-27 12:05:54.952: E/AndroidRuntime(2567):     at android.app.Activity.performCreate(Activity.java:5047)
  06-27 12:05:54.952: E/AndroidRuntime(2567):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
  06-27 12:05:54.952: E/AndroidRuntime(2567):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2045)
  06-27 12:05:54.952: E/AndroidRuntime(2567):     ... 18 more
  06-27 12:05:54.952: E/AndroidRuntime(2567): Caused by: java.lang.ClassCastException: com.google.android.gms.maps.MapFragment cannot be cast to android.support.v4.app.Fragment
  06-27 12:05:54.952: E/AndroidRuntime(2567):     at android.support.v4.app.Fragment.instantiate(Fragment.java:394)
  06-27 12:05:54.952: E/AndroidRuntime(2567):     at android.support.v4.app.Fragment.instantiate(Fragment.java:369)
  06-27 12:05:54.952: E/AndroidRuntime(2567):     at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:272)
  06-27 12:05:54.952: E/AndroidRuntime(2567):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:676)
  06-27 12:05:54.952: E/AndroidRuntime(2567):     ... 28 more
  </code></pre>
  
  <p>I have also added all necessary information into the Manifest.xml (Permissions, API Key etc)</p>
  
  <p><strong>Any help is gratefully appreciated.</strong> :)</p>
  
  <p><strong>EDIT:</strong> Changing <code>android:name="com.google.android.gms.maps.MapFragment"</code> to  <code>android:name="com.google.android.gms.maps.SupportMapFragment"</code> produces the following errors:</p>
  
  <pre><code>06-27 12:11:03.783: I/Process(2567): Sending signal. PID: 2567 SIG: 9
  06-27 12:18:03.192: D/dalvikvm(4617): GC_FOR_ALLOC freed 75K, 14% free 9516K/10951K, paused 30ms, total 30ms
  06-27 12:18:03.202: I/dalvikvm-heap(4617): Grow heap (frag case) to 12.903MB for 2457616-byte allocation
  06-27 12:18:03.232: D/dalvikvm(4617): GC_CONCURRENT freed 6K, 12% free 11910K/13383K, paused 13ms+6ms, total 35ms
  06-27 12:18:04.103: D/libEGL(4617): loaded /system/lib/egl/libEGL_mali.so
  06-27 12:18:04.153: D/libEGL(4617): loaded /system/lib/egl/libGLESv1_CM_mali.so
  06-27 12:18:04.163: D/libEGL(4617): loaded /system/lib/egl/libGLESv2_mali.so
  06-27 12:18:04.423: D/OpenGLRenderer(4617): Enabling debug mode 0
  06-27 12:18:04.613: I/Choreographer(4617): Skipped 59 frames!  The application may be doing too much work on its main thread.
  06-27 12:18:06.795: D/AndroidRuntime(4617): Shutting down VM
  06-27 12:18:06.795: W/dalvikvm(4617): threadid=1: thread exiting with uncaught exception (group=0x412552a0)
  06-27 12:18:06.846: E/AndroidRuntime(4617): FATAL EXCEPTION: main
  06-27 12:18:06.846: E/AndroidRuntime(4617): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.asa.ignite/com.asa.ignite.MapsActivity}: android.view.InflateException: Binary XML file line #8: Error inflating class fragment
  06-27 12:18:06.846: E/AndroidRuntime(4617):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2081)
  06-27 12:18:06.846: E/AndroidRuntime(4617):     at android.app.ActivityThread.startActivityNow(ActivityThread.java:1922)
  06-27 12:18:06.846: E/AndroidRuntime(4617):     at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:135)
  06-27 12:18:06.846: E/AndroidRuntime(4617):     at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:347)
  06-27 12:18:06.846: E/AndroidRuntime(4617):     at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:704)
  06-27 12:18:06.846: E/AndroidRuntime(4617):     at android.widget.TabHost.setCurrentTab(TabHost.java:368)
  06-27 12:18:06.846: E/AndroidRuntime(4617):     at android.widget.TabHost$2.onTabSelectionChanged(TabHost.java:150)
  06-27 12:18:06.846: E/AndroidRuntime(4617):     at android.widget.TabWidget$TabClickListener.onClick(TabWidget.java:546)
  06-27 12:18:06.846: E/AndroidRuntime(4617):     at android.view.View.performClick(View.java:4162)
  06-27 12:18:06.846: E/AndroidRuntime(4617):     at android.view.View$PerformClick.run(View.java:17082)
  06-27 12:18:06.846: E/AndroidRuntime(4617):     at android.os.Handler.handleCallback(Handler.java:615)
  06-27 12:18:06.846: E/AndroidRuntime(4617):     at android.os.Handler.dispatchMessage(Handler.java:92)
  06-27 12:18:06.846: E/AndroidRuntime(4617):     at android.os.Looper.loop(Looper.java:137)
  06-27 12:18:06.846: E/AndroidRuntime(4617):     at android.app.ActivityThread.main(ActivityThread.java:4856)
  06-27 12:18:06.846: E/AndroidRuntime(4617):     at java.lang.reflect.Method.invokeNative(Native Method)
  06-27 12:18:06.846: E/AndroidRuntime(4617):     at java.lang.reflect.Method.invoke(Method.java:511)
  06-27 12:18:06.846: E/AndroidRuntime(4617):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1007)
  06-27 12:18:06.846: E/AndroidRuntime(4617):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:774)
  06-27 12:18:06.846: E/AndroidRuntime(4617):     at dalvik.system.NativeStart.main(Native Method)
  06-27 12:18:06.846: E/AndroidRuntime(4617): Caused by: android.view.InflateException: Binary XML file line #8: Error inflating class fragment
  06-27 12:18:06.846: E/AndroidRuntime(4617):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
  06-27 12:18:06.846: E/AndroidRuntime(4617):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
  06-27 12:18:06.846: E/AndroidRuntime(4617):     at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
  06-27 12:18:06.846: E/AndroidRuntime(4617):     at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
  06-27 12:18:06.846: E/AndroidRuntime(4617):     at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
  06-27 12:18:06.846: E/AndroidRuntime(4617):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:316)
  06-27 12:18:06.846: E/AndroidRuntime(4617):     at android.app.Activity.setContentView(Activity.java:1901)
  06-27 12:18:06.846: E/AndroidRuntime(4617):     at com.asa.ignite.MapsActivity.onCreate(MapsActivity.java:11)
  06-27 12:18:06.846: E/AndroidRuntime(4617):     at android.app.Activity.performCreate(Activity.java:5047)
  06-27 12:18:06.846: E/AndroidRuntime(4617):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
  06-27 12:18:06.846: E/AndroidRuntime(4617):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2045)
  06-27 12:18:06.846: E/AndroidRuntime(4617):     ... 18 more
  06-27 12:18:06.846: E/AndroidRuntime(4617): Caused by: android.support.v4.app.Fragment$InstantiationException: Unable to instantiate fragment com.google.android.gms.maps.SuppourtMapFragment: make sure class name exists, is public, and has an empty constructor that is public
  06-27 12:18:06.846: E/AndroidRuntime(4617):     at android.support.v4.app.Fragment.instantiate(Fragment.java:401)
  06-27 12:18:06.846: E/AndroidRuntime(4617):     at android.support.v4.app.Fragment.instantiate(Fragment.java:369)
  06-27 12:18:06.846: E/AndroidRuntime(4617):     at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:272)
  06-27 12:18:06.846: E/AndroidRuntime(4617):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:676)
  06-27 12:18:06.846: E/AndroidRuntime(4617):     ... 28 more
  06-27 12:18:06.846: E/AndroidRuntime(4617): Caused by: java.lang.ClassNotFoundException: com.google.android.gms.maps.SuppourtMapFragment
  06-27 12:18:06.846: E/AndroidRuntime(4617):     at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
  06-27 12:18:06.846: E/AndroidRuntime(4617):     at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
  06-27 12:18:06.846: E/AndroidRuntime(4617):     at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
  06-27 12:18:06.846: E/AndroidRuntime(4617):     at android.support.v4.app.Fragment.instantiate(Fragment.java:391)
  06-27 12:18:06.846: E/AndroidRuntime(4617):     ... 31 more
  </code></pre>