Updated SDK version, getting ClassNotFoundException: android.support.v4.view.ViewPager
Asked Answered
C

2

27

When i was working on my Android project i found Logcat to be annoying (not keeping the scroll bar at a given point) and read that updating SDK versions adds a pause button to combat this issue. I updated to SDK version 17 and now i am having some strange problems that i didn't have before. I deleted and added the android support library but no luck. Ive been reading around the interwebs but i still cant figure it out. Log is below.

03-22 15:54:18.558: E/AndroidRuntime(11597): FATAL EXCEPTION: main
03-22 15:54:18.558: E/AndroidRuntime(11597): java.lang.RuntimeException: Unable to start   activity ComponentInfo{kris.android/kris.android.ActivityPortfolio}:  android.view.InflateException: Binary XML file line #184: Error inflating class android.support.v4.view.ViewPager
03-22 15:54:18.558: E/AndroidRuntime(11597):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1821)
03-22 15:54:18.558: E/AndroidRuntime(11597):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1842)
03-22 15:54:18.558: E/AndroidRuntime(11597):    at android.app.ActivityThread.access$1500(ActivityThread.java:132)
03-22 15:54:18.558: E/AndroidRuntime(11597):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1038)
03-22 15:54:18.558: E/AndroidRuntime(11597):    at android.os.Handler.dispatchMessage(Handler.java:99)
03-22 15:54:18.558: E/AndroidRuntime(11597):    at android.os.Looper.loop(Looper.java:150)
03-22 15:54:18.558: E/AndroidRuntime(11597):    at android.app.ActivityThread.main(ActivityThread.java:4263)
03-22 15:54:18.558: E/AndroidRuntime(11597):    at java.lang.reflect.Method.invokeNative(Native Method)
03-22 15:54:18.558: E/AndroidRuntime(11597):    at java.lang.reflect.Method.invoke(Method.java:507)
03-22 15:54:18.558: E/AndroidRuntime(11597):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
03-22 15:54:18.558: E/AndroidRuntime(11597):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
03-22 15:54:18.558: E/AndroidRuntime(11597):    at dalvik.system.NativeStart.main(Native Method)
03-22 15:54:18.558: E/AndroidRuntime(11597): Caused by: android.view.InflateException: Binary XML file line #184: Error inflating class android.support.v4.view.ViewPager
03-22 15:54:18.558: E/AndroidRuntime(11597):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:581)
03-22 15:54:18.558: E/AndroidRuntime(11597):    at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
03-22 15:54:18.558: E/AndroidRuntime(11597):    at android.view.LayoutInflater.rInflate(LayoutInflater.java:626)
03-22 15:54:18.558: E/AndroidRuntime(11597):    at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
03-22 15:54:18.558: E/AndroidRuntime(11597):    at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
03-22 15:54:18.558: E/AndroidRuntime(11597):    at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
03-22 15:54:18.558: E/AndroidRuntime(11597):    at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:231)
03-22 15:54:18.558: E/AndroidRuntime(11597):    at android.app.Activity.setContentView(Activity.java:1742)
03-22 15:54:18.558: E/AndroidRuntime(11597):    at kris.android.ActivityPortfolio.onCreate(ActivityPortfolio.java:44)
03-22 15:54:18.558: E/AndroidRuntime(11597):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1072)
03-22 15:54:18.558: E/AndroidRuntime(11597):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1785)
03-22 15:54:18.558: E/AndroidRuntime(11597):    ... 11 more
03-22 15:54:18.558: E/AndroidRuntime(11597): Caused by: java.lang.ClassNotFoundException: android.support.v4.view.ViewPager in loader dalvik.system.PathClassLoader[/data/app/kris.android-2.apk]
03-22 15:54:18.558: E/AndroidRuntime(11597):    at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
03-22 15:54:18.558: E/AndroidRuntime(11597):    at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
03-22 15:54:18.558: E/AndroidRuntime(11597):    at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
03-22 15:54:18.558: E/AndroidRuntime(11597):    at android.view.LayoutInflater.createView(LayoutInflater.java:471)
03-22 15:54:18.558: E/AndroidRuntime(11597):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:570)
03-22 15:54:18.558: E/AndroidRuntime(11597):    ... 21 more
Canopus answered 22/3, 2012 at 21:43 Comment(2)
possible duplicate of Android-SDK r17 ruins working projectsSinglehearted
answer below solved the problem.Canopus
G
92

Go to Project->Properties->Java Build Path than select Order and export tab. Set android-support-v4.jar library checked and up it into top of the list. And then clean and rebuild project.

Gawlas answered 22/3, 2012 at 21:47 Comment(6)
I'm having the same problem... but don't see any "android-support-v4.jar" library listed anywhere. Just Android 4.0.3, Android Dependencies, GoogleAdMobAdsSdk, and my app's src and gen.Theron
@Carol, try right click your project -> Build Path -> Add External Archives. Then add your target archive via the opened file browser. Finally your jar should be listed there.Taub
@Vladimir, i am not sure jar has to be at top of the list. Still great answer, thanks.Taub
+1 .. thx .. after more than 1 year of your answer.. it helps me :)Resor
i had this issue but it was for unable to find class defintion for the com.google.ads.AdRequest. Using Api 16. What Vladimir mentioned worked after a full clean of the project.Halona
@Gokhan, Yes that need not be on the top, just checked is fine.Syracuse
G
0
03-22 15:54:18.558: E/AndroidRuntime(11597): Caused by: java.lang.ClassNotFoundException: android.support.v4.view.ViewPager in loader dalvik.system.PathClassLoader[/data/app/kris.android-2.apk]

I tried moving the JAR's around as per above link, but it did not work for me. What did work was @Vladimir's answer.
If you check your project's .classpath (which was generated pre-SDK.r17), you'll see that it does not contain a classpathentry for android-support-v4.jar. As of SDK.r17, this appears to be a mandatory entry, so @Vladimir's answer hence is correct.

Google tries to (inadequately) explain this.

Garrison answered 27/11, 2012 at 6:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.