G'sson
G'sson

Reputation: 321

Android ViewPager Error

i am working with ViewPager in the android support package v4 but It says that it cant find the ViewPager class in the support package. And i don't know how can fix it?

LOGCAT

04-13 16:48:05.842: E/AndroidRuntime(1211): FATAL EXCEPTION: main
04-13 16:48:05.842: E/AndroidRuntime(1211): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.alpha.liveshitplus/com.alpha.liveshitplus.Discography}: android.view.InflateException: Binary XML file line #6: Error inflating class android.support.v4.view.ViewPager
04-13 16:48:05.842: E/AndroidRuntime(1211):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1955)
04-13 16:48:05.842: E/AndroidRuntime(1211):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1980)
04-13 16:48:05.842: E/AndroidRuntime(1211):     at android.app.ActivityThread.access$600(ActivityThread.java:122)
04-13 16:48:05.842: E/AndroidRuntime(1211):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1146)
04-13 16:48:05.842: E/AndroidRuntime(1211):     at android.os.Handler.dispatchMessage(Handler.java:99)
04-13 16:48:05.842: E/AndroidRuntime(1211):     at android.os.Looper.loop(Looper.java:137)
04-13 16:48:05.842: E/AndroidRuntime(1211):     at android.app.ActivityThread.main(ActivityThread.java:4340)
04-13 16:48:05.842: E/AndroidRuntime(1211):     at java.lang.reflect.Method.invokeNative(Native Method)
04-13 16:48:05.842: E/AndroidRuntime(1211):     at java.lang.reflect.Method.invoke(Method.java:511)
04-13 16:48:05.842: E/AndroidRuntime(1211):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
04-13 16:48:05.842: E/AndroidRuntime(1211):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
04-13 16:48:05.842: E/AndroidRuntime(1211):     at dalvik.system.NativeStart.main(Native Method)
04-13 16:48:05.842: E/AndroidRuntime(1211): Caused by: android.view.InflateException: Binary XML file line #6: Error inflating class android.support.v4.view.ViewPager
04-13 16:48:05.842: E/AndroidRuntime(1211):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:691)
04-13 16:48:05.842: E/AndroidRuntime(1211):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:739)
04-13 16:48:05.842: E/AndroidRuntime(1211):     at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
04-13 16:48:05.842: E/AndroidRuntime(1211):     at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
04-13 16:48:05.842: E/AndroidRuntime(1211):     at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
04-13 16:48:05.842: E/AndroidRuntime(1211):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:251)
04-13 16:48:05.842: E/AndroidRuntime(1211):     at android.app.Activity.setContentView(Activity.java:1835)
04-13 16:48:05.842: E/AndroidRuntime(1211):     at com.alpha.liveshitplus.Discography.onCreate(Discography.java:17)
04-13 16:48:05.842: E/AndroidRuntime(1211):     at android.app.Activity.performCreate(Activity.java:4465)
04-13 16:48:05.842: E/AndroidRuntime(1211):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
04-13 16:48:05.842: E/AndroidRuntime(1211):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1919)
04-13 16:48:05.842: E/AndroidRuntime(1211):     ... 11 more
04-13 16:48:05.842: E/AndroidRuntime(1211): Caused by: java.lang.ClassNotFoundException: android.support.v4.view.ViewPager
04-13 16:48:05.842: E/AndroidRuntime(1211):     at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
04-13 16:48:05.842: E/AndroidRuntime(1211):     at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
04-13 16:48:05.842: E/AndroidRuntime(1211):     at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
04-13 16:48:05.842: E/AndroidRuntime(1211):     at android.view.LayoutInflater.createView(LayoutInflater.java:552)
04-13 16:48:05.842: E/AndroidRuntime(1211):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
04-13 16:48:05.842: E/AndroidRuntime(1211):     ... 21 more

Upvotes: 0

Views: 4852

Answers (3)

mobile internet
mobile internet

Reputation: 71

it is perhaps that the version of android-support-v4.jar is not right. solution:

  1. close the eclipse
  2. delete the android-support-v4.jar in the project's libs folder
  3. reopen the eclipse
  4. right click the project, Android Tools -> Add Support Library... then the eclipse will download the right version of android-support-v4.jar for your project and add it to your project.
  5. rebuilt and run your project, it will OK!

Upvotes: 7

Brian Cooley
Brian Cooley

Reputation: 11662

Given that you upgraded to r18, you might be having trouble with the changes to dependency management. See this link and this link for example.

Upvotes: 0

Shellum
Shellum

Reputation: 3179

Make sure you copy the compatibility jar file into your project's libs folder and add it to your build path.

If a libs folder does not already exist, create one off the root of your project.

Upvotes: 0

Related Questions