Android: class not found exception: android.support.v4.app.FragmentPager
Asked Answered
J

7

21

In my code I import android.support.v4.view.ViewPager but I get a ClassNotFoundException: android.support.v4.view.ViewPager when I set content view to this xml file:

...
 <android.support.v4.app.FragmentPager 
     android:layout_height="0px" 
     android:layout_width="match_parent" 
     android:layout_weight="1" 
     android:id="@+id/pager"> 
     </android.support.v4.app.FragmentPager>
...
Jamisonjammal answered 17/4, 2012 at 21:27 Comment(0)
S
41

You have to add compatibility library by right clicking your project and selecting Android Tools -> Add Compatibility Library. Once its added, clean your project and build again.


enter image description here

Senhorita answered 17/4, 2012 at 21:31 Comment(1)
In my project this resolved issues with missing android.support.v4 library, but I still miss android.support.v13 library!Twice
C
33

i'm using Android Studio Beta 0.8.6 and i had to do it this way


File -> Project Structure enter image description here

Comprehend answered 29/8, 2014 at 16:28 Comment(0)
N
4

Go to <Your android apk folder>\sdk\extras\android\support\v4 folder and add android-support-v4.jar to app library (or whole sdk library).

Natatorium answered 30/10, 2013 at 2:10 Comment(0)
S
3

Add Support library by right clicking your project and selecting Android Tools -> Add Compatibility Library. After adding Support Library clean your project and Go to Java Build Path, Go to Order and Export [Last tab] click all currently added Jar files and libraries..press Ok and refresh your Project.. It works fine for me..

Span answered 29/7, 2013 at 9:46 Comment(0)
R
1

You should add android.support.v4 jar to your app.

Raye answered 17/4, 2012 at 21:30 Comment(2)
i have it and i have android-support-v13.jar which contains a support.v4 folder. strang thing i cannot find a ViewPager, in both folders. is that a problem?Jamisonjammal
hm...it seams android doesnt contains this class at allRaye
F
0

If it is not gradle based then You should Migrate Eclipse ADT based project to Gradle based.. Import Project into android studio..

Fawcette answered 13/7, 2015 at 8:59 Comment(0)
I
0

I had this problem please right click on your project and click Android Tools and now click Support Libraries and then Accept License Now Run your Project It will Work :D

RightClick==>Android Tools==>Support Libraries ==>Accept License

Ignatia answered 8/4, 2016 at 10:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.