title: How to fix InstantiationException, unable to instantiate Fragment?
body: <p>This is my first post, so I apologize in advance...</p>
  
  <p>I'm trying to compile a simple Drawer sample/practice app. When I click on the items in the listview, however, it crashes. Logcat says that it's not able to instantiate from android.app.Fragment. I've tried also using the android.support.v4 library -- assuming I implemented it correctly, which is dubious -- with the same results. Frankly I'm not sure what the difference is. I'm totally stumped. Please help! </p>
  
  <p>MainActivity:</p>
  
  <pre><code>package pac.gazette;
  
  import android.annotation.SuppressLint;
  import android.app.Activity;
  import android.app.Fragment;
  import android.app.FragmentTransaction;
  import android.os.Bundle;
  import android.support.v4.widget.DrawerLayout;
  import android.view.View;
  import android.widget.AdapterView;
  import android.widget.AdapterView.OnItemClickListener;
  import android.widget.ArrayAdapter;
  import android.widget.ListView;
  
  public class MainActivity extends Activity {
  
      private String[] fragmentNames;
      private String[] fragmentAddresses;
  
      private DrawerLayout drawer;
      private ListView drawerList;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          fragmentNames = getResources().getStringArray(R.array.fragment_names);
          fragmentAddresses = getResources().getStringArray(
                  R.array.fragment_options);
          drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
          drawerList = (ListView) findViewById(R.id.left_drawer);
          drawerList.setAdapter(new ArrayAdapter&lt;String&gt;(this,
                  R.layout.drawer_list, fragmentNames));
          drawerList.setOnItemClickListener (new CustomClickListener());
  
      }
  
      public class CustomClickListener implements OnItemClickListener {
  
          @SuppressLint("NewApi") @Override
          public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position,
                  long id) {
              // drawer close handling
              drawer.closeDrawer(drawerList);
              // title handling (does not wait for drawer close)
              if (position == 0) {
                  setTitle(new String("East Asia Gazette"));
              } else {
                  setTitle(fragmentNames[position]);
              }
              // new fragment handling
              FragmentTransaction transaction = getFragmentManager()
                      .beginTransaction();
              transaction.replace(R.id.content_frame, Fragment.instantiate(
                      MainActivity.this, fragmentAddresses[position]));
              transaction.commit();   
          }
      }
  
  }
  </code></pre>
  
  <p>Xml:</p>
  
  <pre><code>&lt;android.support.v4.widget.DrawerLayout
          xmlns:android="http://schemas.android.com/apk/res/android"
          android:id="@+id/drawer_layout"
          android:layout_width="match_parent"
          android:layout_height="match_parent"&gt;
      &lt;!-- The main content view --&gt;
      &lt;FrameLayout
              android:id="@+id/content_frame"
              android:layout_width="match_parent"
              android:layout_height="match_parent"/&gt;
      &lt;!-- The navigation drawer --&gt;
      &lt;ListView
              android:id="@+id/left_drawer"
              android:layout_width="200dp"
              android:layout_height="match_parent"
              android:layout_gravity="start"
              android:choiceMode="singleChoice"
              android:divider="@android:color/transparent"
              android:dividerHeight="0dp"
              android:background="#940032"/&gt;
  &lt;/android.support.v4.widget.DrawerLayout&gt;
  </code></pre>
  
  <p>Logcat:</p>
  
  <pre><code>08-25 12:25:02.579: E/AndroidRuntime(17137): FATAL EXCEPTION: main
  08-25 12:25:02.579: E/AndroidRuntime(17137): android.app.Fragment$InstantiationException: Unable to instantiate fragment pac.gazette.fragment_feed.xml: make sure class name exists, is public, and has an empty constructor that is public
  08-25 12:25:02.579: E/AndroidRuntime(17137):    at android.app.Fragment.instantiate(Fragment.java)
  08-25 12:25:02.579: E/AndroidRuntime(17137):    at android.app.Fragment.instantiate(Fragment.java)
  08-25 12:25:02.579: E/AndroidRuntime(17137):    at pac.gazette.MainActivity$CustomClickListener.onItemClick(MainActivity.java:56)
  08-25 12:25:02.579: E/AndroidRuntime(17137):    at android.widget.AdapterView.performItemClick(AdapterView.java)
  08-25 12:25:02.579: E/AndroidRuntime(17137):    at android.widget.AbsListView.performItemClick(AbsListView.java)
  08-25 12:25:02.579: E/AndroidRuntime(17137):    at android.widget.ListView.performItemClick(ListView.java)
  08-25 12:25:02.579: E/AndroidRuntime(17137):    at android.widget.AbsListView$PerformClick.run(AbsListView.java)
  08-25 12:25:02.579: E/AndroidRuntime(17137):    at android.widget.AbsListView$1.run(AbsListView.java)
  08-25 12:25:02.579: E/AndroidRuntime(17137):    at android.os.Handler.handleCallback(Handler.java)
  08-25 12:25:02.579: E/AndroidRuntime(17137):    at android.os.Handler.dispatchMessage(Handler.java)
  08-25 12:25:02.579: E/AndroidRuntime(17137):    at android.os.Looper.loop(Looper.java)
  08-25 12:25:02.579: E/AndroidRuntime(17137):    at android.app.ActivityThread.main(ActivityThread.java)
  08-25 12:25:02.579: E/AndroidRuntime(17137):    at java.lang.reflect.Method.invokeNative(Native Method)
  08-25 12:25:02.579: E/AndroidRuntime(17137):    at java.lang.reflect.Method.invoke(Method.java)
  08-25 12:25:02.579: E/AndroidRuntime(17137):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java)
  08-25 12:25:02.579: E/AndroidRuntime(17137):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java)
  08-25 12:25:02.579: E/AndroidRuntime(17137):    at dalvik.system.NativeStart.main(Native Method)
  08-25 12:25:02.579: E/AndroidRuntime(17137): Caused by: java.lang.ClassNotFoundException: Didn't find class "pac.gazette.fragment_feed.xml" on path: /data/app/pac.gazette-2.apk
  08-25 12:25:02.579: E/AndroidRuntime(17137):    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java)
  08-25 12:25:02.579: E/AndroidRuntime(17137):    at java.lang.ClassLoader.loadClass(ClassLoader.java)
  08-25 12:25:02.579: E/AndroidRuntime(17137):    at java.lang.ClassLoader.loadClass(ClassLoader.java)
  08-25 12:25:02.579: E/AndroidRuntime(17137):    ... 17 more
  </code></pre>
  
  <p>Manifest:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="pac.gazette"
      android:versionCode="1"
      android:versionName="1.0" &gt;
  
      &lt;uses-sdk
          android:minSdkVersion="8"
          android:targetSdkVersion="17" /&gt;
  
      &lt;application
          android:allowBackup="true"
          android:icon="@drawable/ic_launcher"
          android:label="@string/app_name"
          android:theme="@style/AppTheme" &gt;
          &lt;activity
              android:name="pac.gazette.MainActivity"
              android:label="@string/app_name" &gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.MAIN" /&gt;
  
                  &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
      &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>