2 xiaoliuzi 0 0 xiaoliuzi_0_0 于 2016.03.22 15:55 提问

使用viewpager报这个错是怎么回事

这个是包的什么问题。。。。

 03-22 03:49:15.368: E/AndroidRuntime(1612): FATAL EXCEPTION: main
03-22 03:49:15.368: E/AndroidRuntime(1612): Process: com.example.hospitalmain, PID: 1612
03-22 03:49:15.368: E/AndroidRuntime(1612): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.hospitalmain/com.example.hospitalmain.MainActivity}: android.view.InflateException: Binary XML file line #8: Error inflating class android.support.v4.View.ViewPager
03-22 03:49:15.368: E/AndroidRuntime(1612):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2184)
03-22 03:49:15.368: E/AndroidRuntime(1612):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
03-22 03:49:15.368: E/AndroidRuntime(1612):     at android.app.ActivityThread.access$800(ActivityThread.java:135)
03-22 03:49:15.368: E/AndroidRuntime(1612):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
03-22 03:49:15.368: E/AndroidRuntime(1612):     at android.os.Handler.dispatchMessage(Handler.java:102)
03-22 03:49:15.368: E/AndroidRuntime(1612):     at android.os.Looper.loop(Looper.java:136)
03-22 03:49:15.368: E/AndroidRuntime(1612):     at android.app.ActivityThread.main(ActivityThread.java:5001)
03-22 03:49:15.368: E/AndroidRuntime(1612):     at java.lang.reflect.Method.invokeNative(Native Method)
03-22 03:49:15.368: E/AndroidRuntime(1612):     at java.lang.reflect.Method.invoke(Method.java:515)
03-22 03:49:15.368: E/AndroidRuntime(1612):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
03-22 03:49:15.368: E/AndroidRuntime(1612):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
03-22 03:49:15.368: E/AndroidRuntime(1612):     at dalvik.system.NativeStart.main(Native Method)
03-22 03:49:15.368: E/AndroidRuntime(1612): Caused by: android.view.InflateException: Binary XML file line #8: Error inflating class android.support.v4.View.ViewPager
03-22 03:49:15.368: E/AndroidRuntime(1612):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:707)
03-22 03:49:15.368: E/AndroidRuntime(1612):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
03-22 03:49:15.368: E/AndroidRuntime(1612):     at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
03-22 03:49:15.368: E/AndroidRuntime(1612):     at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
03-22 03:49:15.368: E/AndroidRuntime(1612):     at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
03-22 03:49:15.368: E/AndroidRuntime(1612):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:290)
03-22 03:49:15.368: E/AndroidRuntime(1612):     at android.app.Activity.setContentView(Activity.java:1929)
03-22 03:49:15.368: E/AndroidRuntime(1612):     at com.example.hospitalmain.MainActivity.onCreate(MainActivity.java:13)
03-22 03:49:15.368: E/AndroidRuntime(1612):     at android.app.Activity.performCreate(Activity.java:5231)
03-22 03:49:15.368: E/AndroidRuntime(1612):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
03-22 03:49:15.368: E/AndroidRuntime(1612):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
03-22 03:49:15.368: E/AndroidRuntime(1612):     ... 11 more
03-22 03:49:15.368: E/AndroidRuntime(1612): Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v4.View.ViewPager" on path: DexPathList[[zip file "/data/app/com.example.hospitalmain-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.hospitalmain-1, /system/lib]]
03-22 03:49:15.368: E/AndroidRuntime(1612):     at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
03-22 03:49:15.368: E/AndroidRuntime(1612):     at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
03-22 03:49:15.368: E/AndroidRuntime(1612):     at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
03-22 03:49:15.368: E/AndroidRuntime(1612):     at android.view.LayoutInflater.createView(LayoutInflater.java:559)
03-22 03:49:15.368: E/AndroidRuntime(1612):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
03-22 03:49:15.368: E/AndroidRuntime(1612):     ... 21 more

2个回答

bdmh
bdmh   Ds   Rxr 2016.03.22 16:06
已采纳

布局渲染出错,确认是否存在android.support.v4.View.ViewPager包,或者检查你用的是android.support.v4.View.ViewPager还是Android默认的viewpager,两个不一样

danielinbiti
danielinbiti   Ds   Rxr 2016.03.22 16:00

确认是否有android-support-v4.jar包
如果是发布后的,确认是否这个包也发布出去了
如果是eclipse,需要进行下设置
选择Build Path ->Configure Build Path,然后选择Order and export 选项.把android-support-v4.jar选项勾上
不然发布的时候不会带这个jar

danielinbiti
danielinbiti 回复xiaoliuzi_0_0: 嗯,有时间采纳一下
一年多之前 回复
xiaoliuzi_0_0
xiaoliuzi_0_0 回复danielinbiti: 应该是勾了的。。重写了一次好了。。谢谢
一年多之前 回复
danielinbiti
danielinbiti 回复xiaoliuzi_0_0: 看Order and export中private libraries 是不是选上了。调试有问题吗?
一年多之前 回复
xiaoliuzi_0_0
xiaoliuzi_0_0 噢。。有这个v4包 在private libraries 里面 path里面有选的
一年多之前 回复
xiaoliuzi_0_0
xiaoliuzi_0_0 Order and export 里面没有这个包哈。。。要怎么用。。
一年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!