zoukankan      html  css  js  c++  java
  • 添加androidsupportv4 错误 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包会自动导入项目,不需要手动导入

  • 相关阅读:
    【BZOJ3518】点组计数 欧拉函数
    【BZOJ3677】[Apio2014]连珠线 换根DP
    【BZOJ3678】wangxz与OJ Splay
    【BZOJ3935】Rbtree 树形DP
    【BZOJ3958】[WF2011]Mummy Madness 二分+扫描线+线段树
    (转)Jquery中$.get(),$.post(),$.ajax(),$.getJSON()的用法总结
    string.Format出现异常"输入的字符串格式有误"的解决方法
    c# winForm使用Aspose.Cells读取CSV文件中文乱码问题
    PowerDesigner15.1给自定义架构表字段添加MS_Description出错
    MongoDB 多条件组合查询
  • 原文地址:https://www.cnblogs.com/trinea/p/2771062.html
Copyright © 2011-2022 走看看