title: InflateException Binary XML file at line #7: Error inflating class fragment
body: <p>I've been doing some research of this problem but no solution has yet to work for me. I've added empty constructors in the fragment classes and tried with different imports of fragments, but nothing seems to work. I hope you guys can help me!</p>
  
  <p><strong>My Activity:</strong> </p>
  
  <pre><code>package com.example.com.example.android.rssfeed;
  
  import android.app.Activity;
  import android.os.Bundle;
  
  public class RssfeedActivity extends Activity implements MyListFragment.OnItemSelectedListener {
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_rssfeed);
  }
  
  public void onRssItemSelected(String link) {
      DetailFragment fragment = (DetailFragment) getFragmentManager().findFragmentById(R.id.detailFragment);
  
      if (fragment != null &amp;&amp; fragment.isInLayout()) {
          fragment.setText(link);
      }//end if
  }//end method onRssItemSelected
  
  }//end class
  </code></pre>
  
  <p><strong>My fragment:</strong></p>
  
  <pre><code>package com.example.com.example.android.rssfeed;
  import android.app.Activity;
  import android.os.Bundle;
  import android.app.Fragment;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.Button;
  
  
  public class MyListFragment extends Fragment {
  
  public MyListFragment() {
  
  }
  
  private OnItemSelectedListener listener;
  
  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
      View view = inflater.inflate(R.layout.fragment_rsslist_overview, container, false);
      Button button = (Button) view.findViewById(R.id.btn1);
      button.setOnClickListener(new View.OnClickListener() {
  
          @Override
          public void onClick(View v) {
              updateDetail();
          }//end onClick
      });
      return view;
  }//end onCreateView
  
  public interface OnItemSelectedListener {
      public void onRssItemSelected(String link);
  }//end onItemSelectedListener
  
  @Override
      public void onAttach(Activity activity) {
      super.onAttach(activity);
  
          if (activity instanceof OnItemSelectedListener) {
              listener = (OnItemSelectedListener) activity;
  
          } else {
              throw new ClassCastException(activity.toString()
                      + "Must implement MyListFragment.OnItemSelectedListener");
          }//end else
  
  }//end onAttach
  
  //May also be triggered from the activity
  public void updateDetail() {
      //Create fake data
      String newTime = String.valueOf(System.currentTimeMillis());
      // Send data to Activity
      listener.onRssItemSelected(newTime);
  }//end method updateDetail
  }//end class
  </code></pre>
  
  <p><strong>My fragment XML:</strong></p>
  
  <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:baselineAligned="false"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:orientation="horizontal" &gt;
  
      &lt;fragment
          android:id="@+id/listFragment" 
          android:layout_width="0dp"
          android:layout_weight="1"
          android:layout_height="match_parent"
          class="com.example.android.rssfeed.MyListFragment"
          android:layout_marginTop="?android:attr/actionBarSize"&gt;&lt;/fragment&gt;
  
  
  
      &lt;fragment
          android:id="@+id/detailFragment"
          android:layout_width="0dp"
          android:layout_weight="2"
          android:layout_height="match_parent"
          class="com.example.android.rssfeed.DetailFragment"&gt;&lt;/fragment&gt;
  
  
  
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p><strong>Manifest:</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.example.com.example.android.rssfeed"
  android:versionCode="1"
  android:versionName="1.0" &gt;
  
  &lt;uses-sdk
      android:minSdkVersion="12"
      android:targetSdkVersion="19" /&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="com.example.com.example.android.rssfeed.RssfeedActivity"
          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;
  </code></pre>
  
  <p></p>
  
  <p><strong>Button XML:</strong></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;button
      android:id="@+id/btn1"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="Press to Update"&gt;
  
  &lt;/button&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p><strong>LogCat error:</strong></p>
  
  <pre><code>05-17 10:35:01.864: E/AndroidRuntime(6384): FATAL EXCEPTION: main
  05-17 10:35:01.864: E/AndroidRuntime(6384): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.com.example.android.rssfeed/com.example.com.example.android.rssfeed.RssfeedActivity}: android.view.InflateException: Binary XML file line #7: Error inflating class fragment
  05-17 10:35:01.864: E/AndroidRuntime(6384):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2245)
  05-17 10:35:01.864: E/AndroidRuntime(6384):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2295)
  05-17 10:35:01.864: E/AndroidRuntime(6384):     at android.app.ActivityThread.access$700(ActivityThread.java:150)
  05-17 10:35:01.864: E/AndroidRuntime(6384):     at  android.app.ActivityThread$H.handleMessage(ActivityThread.java:1280)
  05-17 10:35:01.864: E/AndroidRuntime(6384):     at android.os.Handler.dispatchMessage(Handler.java:99)
  05-17 10:35:01.864: E/AndroidRuntime(6384):     at android.os.Looper.loop(Looper.java:137)
  05-17 10:35:01.864: E/AndroidRuntime(6384):     at android.app.ActivityThread.main(ActivityThread.java:5279)
  05-17 10:35:01.864: E/AndroidRuntime(6384):     at java.lang.reflect.Method.invokeNative(Native Method)
  05-17 10:35:01.864: E/AndroidRuntime(6384):     at java.lang.reflect.Method.invoke(Method.java:511)
  05-17 10:35:01.864: E/AndroidRuntime(6384):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
  05-17 10:35:01.864: E/AndroidRuntime(6384):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
  05-17 10:35:01.864: E/AndroidRuntime(6384):     at dalvik.system.NativeStart.main(Native Method)
  05-17 10:35:01.864: E/AndroidRuntime(6384): Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class fragment
  05-17 10:35:01.864: E/AndroidRuntime(6384):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:710)
  05-17 10:35:01.864: E/AndroidRuntime(6384):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:752)
  05-17 10:35:01.864: E/AndroidRuntime(6384):     at android.view.LayoutInflater.inflate(LayoutInflater.java:495)
  05-17 10:35:01.864: E/AndroidRuntime(6384):     at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
  05-17 10:35:01.864: E/AndroidRuntime(6384):     at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
  05-17 10:35:01.864: E/AndroidRuntime(6384):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:342)
  05-17 10:35:01.864: E/AndroidRuntime(6384):     at android.app.Activity.setContentView(Activity.java:1928)
  05-17 10:35:01.864: E/AndroidRuntime(6384):     at com.example.com.example.android.rssfeed.RssfeedActivity.onCreate(RssfeedActivity.java:11)
  05-17 10:35:01.864: E/AndroidRuntime(6384):     at android.app.Activity.performCreate(Activity.java:5267)
  05-17 10:35:01.864: E/AndroidRuntime(6384):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1097)
  05-17 10:35:01.864: E/AndroidRuntime(6384):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2209)
  05-17 10:35:01.864: E/AndroidRuntime(6384):     ... 11 more
  05-17 10:35:01.864: E/AndroidRuntime(6384): Caused by: android.app.Fragment$InstantiationException: Unable to instantiate fragment com.example.android.rssfeed.MyListFragment: make sure class name exists, is public, and has an empty constructor that is public
  05-17 10:35:01.864: E/AndroidRuntime(6384):     at android.app.Fragment.instantiate(Fragment.java:592)
  05-17 10:35:01.864: E/AndroidRuntime(6384):     at android.app.Fragment.instantiate(Fragment.java:560)
  05-17 10:35:01.864: E/AndroidRuntime(6384):     at android.app.Activity.onCreateView(Activity.java:4862)
  05-17 10:35:01.864: E/AndroidRuntime(6384):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:686)
  05-17 10:35:01.864: E/AndroidRuntime(6384):     ... 21 more
  05-17 10:35:01.864: E/AndroidRuntime(6384): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.android.rssfeed.MyListFragment" on path: /data/app/com.example.com.example.android.rssfeed-1.apk
  05-17 10:35:01.864: E/AndroidRuntime(6384):     at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65)
  05-17 10:35:01.864: E/AndroidRuntime(6384):     at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
  05-17 10:35:01.864: E/AndroidRuntime(6384):     at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
  05-17 10:35:01.864: E/AndroidRuntime(6384):     at android.app.Fragment.instantiate(Fragment.java:582)
  05-17 10:35:01.864: E/AndroidRuntime(6384):     ... 24 more
  </code></pre>