本文介绍了膨胀类android.support.v7.widget.RecyclerView(Eclipse)时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在eclipse的android项目中使用android.support.v7.widget.RecyclerView

I want use android.support.v7.widget.RecyclerView in my android project in eclipse

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="ir.sheikhoo.sis.EditeActivity" >

    <android.support.v7.widget.RecyclerView
        android:id="@+id/recyclerView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
    </android.support.v7.widget.RecyclerView>

</RelativeLayout>

但是会引发错误

09-23 11:33:37.968: E/AndroidRuntime(20310): java.lang.RuntimeException: Unable to start activity ComponentInfo{ir.sheikhoo.sis/ir.sheikhoo.sis.EditeActivity}: android.view.InflateException: Binary XML file line #11: Error inflating class android.support.v7.widget.RecyclerView

完整的错误日志

09-23 11:55:53.288: E/AndroidRuntime(28333): FATAL EXCEPTION: main
09-23 11:55:53.288: E/AndroidRuntime(28333): Process: ir.sheikhoo.sis, PID: 28333
09-23 11:55:53.288: E/AndroidRuntime(28333): java.lang.RuntimeException: Unable to start activity ComponentInfo{ir.sheikhoo.sis/ir.sheikhoo.sis.EditeActivity}: android.view.InflateException: Binary XML file line #11: Error inflating class android.support.v7.widget.RecyclerView
09-23 11:55:53.288: E/AndroidRuntime(28333):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2429)
09-23 11:55:53.288: E/AndroidRuntime(28333):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2493)
09-23 11:55:53.288: E/AndroidRuntime(28333):    at android.app.ActivityThread.access$800(ActivityThread.java:166)
09-23 11:55:53.288: E/AndroidRuntime(28333):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1283)
09-23 11:55:53.288: E/AndroidRuntime(28333):    at android.os.Handler.dispatchMessage(Handler.java:102)
09-23 11:55:53.288: E/AndroidRuntime(28333):    at android.os.Looper.loop(Looper.java:136)
09-23 11:55:53.288: E/AndroidRuntime(28333):    at android.app.ActivityThread.main(ActivityThread.java:5590)
09-23 11:55:53.288: E/AndroidRuntime(28333):    at java.lang.reflect.Method.invokeNative(Native Method)
09-23 11:55:53.288: E/AndroidRuntime(28333):    at java.lang.reflect.Method.invoke(Method.java:515)
09-23 11:55:53.288: E/AndroidRuntime(28333):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1280)
09-23 11:55:53.288: E/AndroidRuntime(28333):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1096)
09-23 11:55:53.288: E/AndroidRuntime(28333):    at dalvik.system.NativeStart.main(Native Method)
09-23 11:55:53.288: E/AndroidRuntime(28333): Caused by: android.view.InflateException: Binary XML file line #11: Error inflating class android.support.v7.widget.RecyclerView
09-23 11:55:53.288: E/AndroidRuntime(28333):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:714)
09-23 11:55:53.288: E/AndroidRuntime(28333):    at android.view.LayoutInflater.rInflate(LayoutInflater.java:762)
09-23 11:55:53.288: E/AndroidRuntime(28333):    at android.view.LayoutInflater.inflate(LayoutInflater.java:499)
09-23 11:55:53.288: E/AndroidRuntime(28333):    at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
09-23 11:55:53.288: E/AndroidRuntime(28333):    at android.view.LayoutInflater.inflate(LayoutInflater.java:354)
09-23 11:55:53.288: E/AndroidRuntime(28333):    at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:331)
09-23 11:55:53.288: E/AndroidRuntime(28333):    at android.app.Activity.setContentView(Activity.java:2018)
09-23 11:55:53.288: E/AndroidRuntime(28333):    at ir.sheikhoo.sis.EditeActivity.onCreate(EditeActivity.java:13)
09-23 11:55:53.288: E/AndroidRuntime(28333):    at android.app.Activity.performCreate(Activity.java:5447)
09-23 11:55:53.288: E/AndroidRuntime(28333):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
09-23 11:55:53.288: E/AndroidRuntime(28333):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2393)
09-23 11:55:53.288: E/AndroidRuntime(28333):    ... 11 more
09-23 11:55:53.288: E/AndroidRuntime(28333): Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v7.widget.RecyclerView" on path: DexPathList[[zip file "/data/app/ir.sheikhoo.sis-22.apk"],nativeLibraryDirectories=[/data/app-lib/ir.sheikhoo.sis-22, /vendor/lib, /system/lib]]
09-23 11:55:53.288: E/AndroidRuntime(28333):    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
09-23 11:55:53.288: E/AndroidRuntime(28333):    at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
09-23 11:55:53.288: E/AndroidRuntime(28333):    at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
09-23 11:55:53.288: E/AndroidRuntime(28333):    at android.view.LayoutInflater.createView(LayoutInflater.java:566)
09-23 11:55:53.288: E/AndroidRuntime(28333):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:703)
09-23 11:55:53.288: E/AndroidRuntime(28333):    ... 21 more

我使用android.support-23.2.1和目标sdk android:targetSdkVersion="23"

I use android.support-23.2.1 and target sdk android:targetSdkVersion="23"

这是我的sdk

推荐答案

我认为您的 cardview jar文件中的问题,它与其他库的版本不匹配.

I think the problem in your cardview jar file, it does not match version with other libraries.

首先,您需要使用 cardview 或其他版本低于 compileSdkVersion和targetSdkVersion 的库.在这种情况下,您使用版本 cardview-v7-21.0.0.jar ,因此您的 compileSdkVersion和targetSdkVersion 必须为21.0.0或更高版本.

1st, you mast need to use cardview or other libraries version less than compileSdkVersion and targetSdkVersion. In this case you use version cardview-v7-21.0.0.jar so your compileSdkVersion and targetSdkVersion must be 21.0.0 or upper.

2,我认为您需要切换Android Studio,这使得管理库变得很容易.

2nd, I think you need to switch Android Studio it's made easy to manage libraries.

这篇关于膨胀类android.support.v7.widget.RecyclerView(Eclipse)时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-01 16:53