Didn't find class "android.support.v7.widget.RecyclerView

后端 未结 6 976
生来不讨喜
生来不讨喜 2021-01-07 23:58

I\'m getting this exception when running:

android.view.InflateException: Binary XML file line #8: Error inflating class android.support.v7.widget.RecyclerView

相关标签:
6条回答
  • 2021-01-08 00:28

    This is my eclipse journey to complete my mqtt project.

    First of all, you have to check if the support library exists, if not you have to download it using sdk manager.

    I know you've already got that library. Just check the directory where the support library is. You are sure to confirm there are four directories existed on the picture.

    In your case, you will have two core libraries both appcompat-v7 and support-v4 that are all version 22 or higher at least.

    There must be a aar file in each folders. you have to change the suffix aar to zip, then unzip it under the folder. Rename both classes.jar to appcompat-v7-22.1.0.jar and support-v4-22.1.0.jar.

    It means that you are ready to copy them to the proper libs folder in your project.

    you do the same action with both folders.

    In the recyclerview-v7\21.0.0 folder, you can juse rename the classes.jar to whatever name you want and the support-annotations-21.0.0.jar under the support-annotations\21.0.0\ then copy them to the your libs folder of your project.

    Import existing android projects to your eclipse,

    Also, do the same thing with the support-v4-22.1.0 library.

    Don't forget check the checkbox - 'Is Library'

    You can finally set up all configuration for your project like picture as follows.

    This is my project.properties file.

    target=android-21
    
    java.target=1.7
    java.source=1.7
    
    android.library.reference.1=..\\MqttService
    android.library.reference.2=..\\extras\\android\\m2repository\\com\\android\\support\\appcompat-v7\\22.1.0\\appcompat-v7-22.1.0
    android.library.reference.3=..\\extras\\android\\m2repository\\com\\android\\support\\support-v4\\22.1.0\\support-v4-22.1.0
    
    0 讨论(0)
  • 2021-01-08 00:43

    In eclipse in your workspace, create a new project using the existing code, then select path to Recycler in android SDK support and in properties select compiler google API 20 or 21 and check Is Library.

    After that, in the workspace select your own project, right-click properties and go to android section and in library click add button and select your Recycler project from list.

    Next you must do clean all project from project menu .

    Sorry if my english is so bad but its ur solution and just adding suuport v7 as jar through errors its not like v4.

    0 讨论(0)
  • 2021-01-08 00:43

    If you do not know which jar file contains the class your are looking for you can use this bash command. On Windows, you can run it if you install Cygwin.

    for i in find . -name \*.jar ; do echo $i; jar tvf $i | fgrep $*; done

    This should search in the subdirectories and help you find the missing jar file.

    0 讨论(0)
  • 2021-01-08 00:46

    Switching to Android Studio is a better option but the rendering problem is still there.

    To remove the same in Android Studio, add the "Gradle Dependencies" into your module.

     dependencies {
        ...
        compile 'com.android.support:recyclerview-v7:21.0.+'
       }
    

    Hope this helps somebody as it helped me. This is a small change but very annoying.

    0 讨论(0)
  • 2021-01-08 00:49

    If you are updated your android studio to v-3.4.2

    then Change from

    android.support.v7.widget.RecyclerView
    

    to

    androidx.recyclerview.widget.RecyclerView
    

    it's work for me.

    0 讨论(0)
  • 2021-01-08 00:49
    Simple Two Steps:
    
    In stand off
    
    <android.support.v7.widget.RecyclerView
                android:id="@+id/rv_News"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:scrollbars="vertical" />  
    
    Replace with androidx package in xml file as below
    
    <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/recyclerView"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:scrollbars="vertical" />
    
    @Ambilpura
    
    0 讨论(0)
提交回复
热议问题