迁移到 www.trinea.cn @Android @Java @性能优化 @开源,滴滴国际化项目 Android 端演进

添加android-support-v4 错误 java.lang.ClassNotFoundException: android.support.v4.view.ViewPager in loader dalvik.system.PathClassLoader

在使用ViewPager添加android-support-v4.jar后提示如下错误

11-15 21:01:21.725: E/AndroidRuntime(32431): Caused by: java.lang.ClassNotFoundException: android.support.v4.view.ViewPager in loader dalvik.system.PathClassLoader[/system/framework/com.google.android.maps.jar:/mnt/asec/com.trinea.android.demo-2/pkg.apk]

完整错误为:

完整错误
11-15 21:01:21.725: E/AndroidRuntime(32431): FATAL EXCEPTION: main
11-15 21:01:21.725: E/AndroidRuntime(32431): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.trinea.android.demo/com.trinea.android.demo.ViewPagerDemo}: android.view.InflateException: Binary XML file line #7: Error inflating class android.support.v4.view.ViewPager
11-15 21:01:21.725: E/AndroidRuntime(32431):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1664)
11-15 21:01:21.725: E/AndroidRuntime(32431):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1680)
11-15 21:01:21.725: E/AndroidRuntime(32431):     at android.app.ActivityThread.access$1500(ActivityThread.java:117)
11-15 21:01:21.725: E/AndroidRuntime(32431):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
11-15 21:01:21.725: E/AndroidRuntime(32431):     at android.os.Handler.dispatchMessage(Handler.java:99)
11-15 21:01:21.725: E/AndroidRuntime(32431):     at android.os.Looper.loop(Looper.java:130)
11-15 21:01:21.725: E/AndroidRuntime(32431):     at android.app.ActivityThread.main(ActivityThread.java:3703)
11-15 21:01:21.725: E/AndroidRuntime(32431):     at java.lang.reflect.Method.invokeNative(Native Method)
11-15 21:01:21.725: E/AndroidRuntime(32431):     at java.lang.reflect.Method.invoke(Method.java:507)
11-15 21:01:21.725: E/AndroidRuntime(32431):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
11-15 21:01:21.725: E/AndroidRuntime(32431):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
11-15 21:01:21.725: E/AndroidRuntime(32431):     at dalvik.system.NativeStart.main(Native Method)
11-15 21:01:21.725: E/AndroidRuntime(32431): Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class android.support.v4.view.ViewPager
11-15 21:01:21.725: E/AndroidRuntime(32431):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:581)
11-15 21:01:21.725: E/AndroidRuntime(32431):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
11-15 21:01:21.725: E/AndroidRuntime(32431):     at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
11-15 21:01:21.725: E/AndroidRuntime(32431):     at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
11-15 21:01:21.725: E/AndroidRuntime(32431):     at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
11-15 21:01:21.725: E/AndroidRuntime(32431):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:212)
11-15 21:01:21.725: E/AndroidRuntime(32431):     at android.app.Activity.setContentView(Activity.java:1681)
11-15 21:01:21.725: E/AndroidRuntime(32431):     at com.trinea.android.demo.ViewPagerDemo.onCreate(ViewPagerDemo.java:28)
11-15 21:01:21.725: E/AndroidRuntime(32431):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
11-15 21:01:21.725: E/AndroidRuntime(32431):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1628)
11-15 21:01:21.725: E/AndroidRuntime(32431):     ... 11 more
11-15 21:01:21.725: E/AndroidRuntime(32431): Caused by: java.lang.ClassNotFoundException: android.support.v4.view.ViewPager in loader dalvik.system.PathClassLoader[/system/framework/com.google.android.maps.jar:/mnt/asec/com.trinea.android.demo-2/pkg.apk]
11-15 21:01:21.725: E/AndroidRuntime(32431):     at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
11-15 21:01:21.725: E/AndroidRuntime(32431):     at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
11-15 21:01:21.725: E/AndroidRuntime(32431):     at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
11-15 21:01:21.725: E/AndroidRuntime(32431):     at android.view.LayoutInflater.createView(LayoutInflater.java:471)
11-15 21:01:21.725: E/AndroidRuntime(32431):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:570)

我是通过项目 -> 属性 -> Java Build Path -> Add External JARs添加了android-support-v4.jar包的,解决只需要项目 -> 属性 -> Java Build Path -> Remove该jar,直接将jar包复制到项目的libs目录下即可。因为项目libs下的jar包会自动导入项目,不需要手动导入

 

posted @ 2012-11-16 19:04  Trinea  阅读(12595)  评论(1编辑  收藏  举报