Android ClassNotFoundException with ViewPager Android ClassNotFoundException with ViewPager android android

Android ClassNotFoundException with ViewPager


What does your XML look like in the layout file? If you simply put

<ViewPager    android:layout_width="..."    android:layout_height="..." />

Your application will crash because ViewPager is not located in the core SDK package with other widgets, it's in the support library. You need to put the fully qualified name

<android.support.v4.view.ViewPager    android:layout_width="..."    android:layout_height="..." />

Also, as others have mentioned, make sure the support library JAR is properly included in your project.

HTH


I think you have a few too many super prefixes there.

Try this:

@Override   public void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.main);       this.myAdapter = new StockPageAdapter(this);       this.myPager = (ViewPager)findViewById(R.id.pager);       this.myPager.setAdapter(myAdapter);   }   

Also, make sure the android-support-v4.jar is in a directory called libs (which should be in your project and on the same level as res and src and assets). This is a must now as of ADT 17 (IIRC). Just create that directory, drop the .jar in there and Eclipse will take care of the rest, no need to try and add it manually to the build path or anything.