title: Error inflating class android.support.v4.view.ViewPager
body: <p>I've been trying to create a Pager for my application that runs on <code>&lt;uses-sdk android:minSdkVersion="10" android:targetSdkVersion="15" /&gt;</code> I wrote my code according to <a href="http://mobile.tutsplus.com/tutorials/android/android-user-interface-design-horizontal-view-paging/">this blog post</a>. </p>
  
  <p><strong>XML for Pager activity:</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;android.support.v4.view.ViewPager
          android:id="@+id/instructionsViewPager"
          android:layout_width="match_parent"
          android:layout_height="match_parent" /&gt; 
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p><strong>Code for adapter:</strong></p>
  
  <pre><code>public class MyPagerAdapter extends PagerAdapter {
  
      @Override
      public int getCount() {
          // TODO Auto-generated method stub
          return 2;
      }
  
      @Override
      public boolean isViewFromObject(View arg0, Object arg1) {
          return (arg0 == ((View) arg1));
      }
  
      @Override
      public void destroyItem(ViewGroup container, int position, Object object) {
          ((ViewPager) container).removeView((View) object);
      }
  
      @Override
      public Object instantiateItem(ViewGroup container, int position) {
          LayoutInflater inflater = (LayoutInflater) container.getContext()
                  .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
          int resId = 0;
          switch (position) {
          case 1:
              resId = R.layout.instructions_page1;
              break;
          case 2:
              resId = R.layout.instructions_page2;
              break;
          }
          View view = inflater.inflate(resId, null);
          ((ViewPager) container).addView(view, 0);
          return view;
      }
  }
  </code></pre>
  
  <p><strong>Code for activity</strong></p>
  
  <pre><code>public class Instructions extends Activity {
  
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.instructions);
  
          MyPagerAdapter adapter = new MyPagerAdapter();
          ViewPager pager = (ViewPager) findViewById(R.id.instructionsViewPager);
          pager.setAdapter(adapter);
          pager.setCurrentItem(0);
      }
  }
  </code></pre>
  
  <p>for some reason, when I run this app, I get this following error list:</p>
  
  <pre><code>05-28 09:38:54.535: E/AndroidRuntime(18658): FATAL EXCEPTION: main
  05-28 09:38:54.535: E/AndroidRuntime(18658): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.thepoosh/com.thepoosh.Instructions}: android.view.InflateException: Binary XML file line #7: Error inflating class android.support.v4.view.ViewPager
  05-28 09:38:54.535: E/AndroidRuntime(18658):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651)
  05-28 09:38:54.535: E/AndroidRuntime(18658):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
  05-28 09:38:54.535: E/AndroidRuntime(18658):    at android.app.ActivityThread.access$1500(ActivityThread.java:117)
  05-28 09:38:54.535: E/AndroidRuntime(18658):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
  05-28 09:38:54.535: E/AndroidRuntime(18658):    at android.os.Handler.dispatchMessage(Handler.java:99)
  05-28 09:38:54.535: E/AndroidRuntime(18658):    at android.os.Looper.loop(Looper.java:123)
  05-28 09:38:54.535: E/AndroidRuntime(18658):    at android.app.ActivityThread.main(ActivityThread.java:3691)
  05-28 09:38:54.535: E/AndroidRuntime(18658):    at java.lang.reflect.Method.invokeNative(Native Method)
  05-28 09:38:54.535: E/AndroidRuntime(18658):    at java.lang.reflect.Method.invoke(Method.java:507)
  05-28 09:38:54.535: E/AndroidRuntime(18658):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:847)
  05-28 09:38:54.535: E/AndroidRuntime(18658):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605)
  05-28 09:38:54.535: E/AndroidRuntime(18658):    at dalvik.system.NativeStart.main(Native Method)
  05-28 09:38:54.535: E/AndroidRuntime(18658): Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class android.support.v4.view.ViewPager
  05-28 09:38:54.535: E/AndroidRuntime(18658):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:581)
  05-28 09:38:54.535: E/AndroidRuntime(18658):    at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
  05-28 09:38:54.535: E/AndroidRuntime(18658):    at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
  05-28 09:38:54.535: E/AndroidRuntime(18658):    at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
  05-28 09:38:54.535: E/AndroidRuntime(18658):    at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
  05-28 09:38:54.535: E/AndroidRuntime(18658):    at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:207)
  05-28 09:38:54.535: E/AndroidRuntime(18658):    at android.app.Activity.setContentView(Activity.java:1663)
  05-28 09:38:54.535: E/AndroidRuntime(18658):    at com.thepoosh.Instructions.onCreate(Instructions.java:11)
  05-28 09:38:54.535: E/AndroidRuntime(18658):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
  05-28 09:38:54.535: E/AndroidRuntime(18658):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615)
  05-28 09:38:54.535: E/AndroidRuntime(18658):    ... 11 more
  05-28 09:38:54.535: E/AndroidRuntime(18658): Caused by: java.lang.ClassNotFoundException: android.support.v4.view.ViewPager in loader dalvik.system.PathClassLoader[/data/app/com.thepoosh-1.apk]
  05-28 09:38:54.535: E/AndroidRuntime(18658):    at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
  05-28 09:38:54.535: E/AndroidRuntime(18658):    at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
  05-28 09:38:54.535: E/AndroidRuntime(18658):    at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
  05-28 09:38:54.535: E/AndroidRuntime(18658):    at android.view.LayoutInflater.createView(LayoutInflater.java:471)
  05-28 09:38:54.535: E/AndroidRuntime(18658):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:570)
  05-28 09:38:54.535: E/AndroidRuntime(18658):    ... 20 more
  </code></pre>
  
  <p>so, I know it's failing because I'm using the <code>android.support.v4.view.ViewPager</code>, I tried playing with that and changing to plain <code>ViewPager</code> and importing <code>android.support.v13</code> but it didn't help...</p>
  
  <p>any thoughts on how to fix this?</p>