title: Action Bar Sherlock + Fragments?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/9042493/exception-right-off-the-bat">Exception right off the bat</a>  </p>
  </blockquote>
  
  
  
  <p>I'm trying to use a dashboard fragment on my main page after installing Action Bar Sherlock.  I'm getting the error:</p>
  
  <p>"Error inflating class fragment"</p>
  
  <p>I've installed Action Bar Sherlock as a library project.  Here is the XAML:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"&gt;
  
  &lt;Fragment 
      class="myVirtualHealthCheck.com.Android.fragments.DashboardFragment"
      android:layout_width="fill_parent"
      android:layout_height="0dip"/&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>aMainMenu.java</p>
  
  <pre><code>package myVirtualHealthCheck.com.Android.ui;
  
  import java.io.IOException;
  import java.io.InputStream;
  import java.io.InputStreamReader;
  import java.net.URI;
  
  import myVirtualHealthCheck.com.Android.R;
  
  import org.apache.http.HttpEntity;
  import org.apache.http.HttpResponse;
  import org.apache.http.client.methods.HttpGet;
  import org.apache.http.impl.client.DefaultHttpClient;
  
  import android.content.Intent;
  import android.content.SharedPreferences;
  import android.os.Bundle;
  import android.support.v4.app.FragmentActivity;
  import android.util.Log;
  import android.view.Menu;
  import android.view.MenuInflater;
  import android.view.MenuItem;
  
  
  public class aMainMenu extends FragmentActivity{
  </code></pre>
  
  <p>DashboardFragment.java: </p>
  
  <pre><code>    package myVirtualHealthCheck.com.Android.fragments;
  
      import myVirtualHealthCheck.com.Android.R;
      import myVirtualHealthCheck.com.Android.ui.aNutritionLookup;
      import myVirtualHealthCheck.com.Android.ui.aPlaces;
      import myVirtualHealthCheck.com.Android.ui.aVitalAdd;
      import myVirtualHealthCheck.com.Android.ui.aVitalsMy;
      import myVirtualHealthCheck.com.Android.utils.AnalyticsUtils;
      import android.content.Intent;
      import android.net.Uri;
      import android.os.Bundle;
      import android.support.v4.app.Fragment;
      import android.view.LayoutInflater;
      import android.view.View;
      import android.view.ViewGroup;
  
  
      public class DashboardFragment extends Fragment {
  
      public void fireTrackerEvent(String label) {
          AnalyticsUtils.getInstance(getActivity()).trackEvent("Home Screen Dashboard", "Click", label, 0);
      }
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
          View root = inflater.inflate(R.layout.fragment_dashboard, container);
  
          // MY VITALS *CLICK*
          root.findViewById(R.id.btnVitalsMy).setOnClickListener(new View.OnClickListener() {
              public void onClick(View view) {
                  fireTrackerEvent("VitalsMy");
                  startActivity(new Intent(getActivity(), aVitalsMy.class));
              }
          });
  
          // ADD VITAL *CLICK*
          root.findViewById(R.id.btnVitalAdd).setOnClickListener(new View.OnClickListener() {
              public void onClick(View view) {
                  fireTrackerEvent("VitalAdd");
                  startActivity(new Intent(getActivity(), aVitalAdd.class));
              }
          });
  
          // NUTRITION *CLICK*
          root.findViewById(R.id.btnNutrition).setOnClickListener(new View.OnClickListener() {
              public void onClick(View view) {
                  fireTrackerEvent("NutritionLookup");
                  startActivity(new Intent(getActivity(), aNutritionLookup.class));                
              }
          });
  
          // PLACES *CLICK*
          root.findViewById(R.id.btnPlaces).setOnClickListener(new View.OnClickListener() {
              public void onClick(View view) {
                  fireTrackerEvent("Places");
                  startActivity(new Intent(getActivity(), aPlaces.class));                
              }
          });
  
          // TWITTER *CLICK*
          root.findViewById(R.id.btnTwitter).setOnClickListener(new View.OnClickListener() {
              public void onClick(View view) {
                  fireTrackerEvent("Twitter");
                  startActivity(new Intent("android.intent.action.VIEW", Uri.parse("http://twitter.com/#!/WellnessCheck")));                
              }
          });
  
          // Facebook *CLICK*
          root.findViewById(R.id.btnFacebook).setOnClickListener(new View.OnClickListener() {
              public void onClick(View view) {
                  fireTrackerEvent("Facebook");
                  startActivity(new Intent("android.intent.action.VIEW", Uri.parse("http://www.facebook.com/myvhc")));                
              }
          });
  
  
  
          return root;
      }
  }
  </code></pre>
  
  <p>here is the logcat:</p>
  
  <pre><code>02-01 08:53:01.014: W/dalvikvm(8023): threadid=1: thread exiting with uncaught exception (group=0x40020950)
  02-01 08:53:01.114: E/AndroidRuntime(8023): FATAL EXCEPTION: main
  02-01 08:53:01.114: E/AndroidRuntime(8023): java.lang.RuntimeException: Unable to start activity ComponentInfo{myVirtualHealthCheck.com.Android/myVirtualHealthCheck.com.Android.ui.aMainMenu}: android.view.InflateException: Binary XML file line #8: Error inflating class Fragment
  02-01 08:53:01.114: E/AndroidRuntime(8023):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
  02-01 08:53:01.114: E/AndroidRuntime(8023):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
  02-01 08:53:01.114: E/AndroidRuntime(8023):     at android.app.ActivityThread.access$2300(ActivityThread.java:125)
  02-01 08:53:01.114: E/AndroidRuntime(8023):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
  02-01 08:53:01.114: E/AndroidRuntime(8023):     at android.os.Handler.dispatchMessage(Handler.java:99)
  02-01 08:53:01.114: E/AndroidRuntime(8023):     at android.os.Looper.loop(Looper.java:123)
  02-01 08:53:01.114: E/AndroidRuntime(8023):     at android.app.ActivityThread.main(ActivityThread.java:4627)
  02-01 08:53:01.114: E/AndroidRuntime(8023):     at java.lang.reflect.Method.invokeNative(Native Method)
  02-01 08:53:01.114: E/AndroidRuntime(8023):     at java.lang.reflect.Method.invoke(Method.java:521)
  02-01 08:53:01.114: E/AndroidRuntime(8023):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:893)
  02-01 08:53:01.114: E/AndroidRuntime(8023):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:651)
  02-01 08:53:01.114: E/AndroidRuntime(8023):     at dalvik.system.NativeStart.main(Native Method)
  02-01 08:53:01.114: E/AndroidRuntime(8023): Caused by: android.view.InflateException: Binary XML file line #8: Error inflating class Fragment
  02-01 08:53:01.114: E/AndroidRuntime(8023):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:576)
  02-01 08:53:01.114: E/AndroidRuntime(8023):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
  02-01 08:53:01.114: E/AndroidRuntime(8023):     at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
  02-01 08:53:01.114: E/AndroidRuntime(8023):     at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
  02-01 08:53:01.114: E/AndroidRuntime(8023):     at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
  02-01 08:53:01.114: E/AndroidRuntime(8023):     at android.support.v4.app.FragmentActivity.setContentView(FragmentActivity.java:421)
  02-01 08:53:01.114: E/AndroidRuntime(8023):     at myVirtualHealthCheck.com.Android.ui.aMainMenu.onCreate(aMainMenu.java:32)
  02-01 08:53:01.114: E/AndroidRuntime(8023):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
  02-01 08:53:01.114: E/AndroidRuntime(8023):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
  02-01 08:53:01.114: E/AndroidRuntime(8023):     ... 11 more
  02-01 08:53:01.114: E/AndroidRuntime(8023): Caused by: java.lang.ClassNotFoundException: android.view.Fragment in loader dalvik.system.PathClassLoader[/data/app/myVirtualHealthCheck.com.Android-1.apk]
  02-01 08:53:01.114: E/AndroidRuntime(8023):     at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
  02-01 08:53:01.114: E/AndroidRuntime(8023):     at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
  02-01 08:53:01.114: E/AndroidRuntime(8023):     at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
  02-01 08:53:01.114: E/AndroidRuntime(8023):     at android.view.LayoutInflater.createView(LayoutInflater.java:466)
  02-01 08:53:01.114: E/AndroidRuntime(8023):     at android.view.LayoutInflater.onCreateView(LayoutInflater.java:544)
  02-01 08:53:01.114: E/AndroidRuntime(8023):     at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:66)
  02-01 08:53:01.114: E/AndroidRuntime(8023):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
  02-01 08:53:01.114: E/AndroidRuntime(8023):     ... 19 more
  </code></pre>