Error inflating class and android.support.v7.widget.CardView

后端 未结 15 1490
-上瘾入骨i
-上瘾入骨i 2020-11-27 20:47

I want to use CardView in my project, but when I run my application, I get the following error. I\'m using Eclipse.

Error: Error inflating clas         


        
相关标签:
15条回答
  • 2020-11-27 21:18

    import the CardView library as the Eclipse Project instead of the Android Project

    0 讨论(0)
  • 2020-11-27 21:19

    This solution work on me.

    1- Go to "sdk\extras\android\m2repository\com\android\support\recyclerview-v7*22.1.1*" ( 22.1.1 latest version for now. )

    2- Open recyclerview-v7-22.1.1.aar file with Winrar.

    3- There is a jar file named classes.jar. Copy that to your project libs folder.

    4- Right click classes.jar, add to build path.

    Thats it.

    0 讨论(0)
  • 2020-11-27 21:23

    To fix this problem . first you must add cardview from the

    1. Close the main project.
    2. Remove the android-support-v7-appcompat .
    3. Restart the Eclipse.
    4. Add the android-support-v7-appcompat .
    5. Clean,To build the project.
    6. Then open the main project and build all the projects.
    7. The error still remains. Restart eclipse. That's it.

    That works for me.

    0 讨论(0)
  • 2020-11-27 21:23

    Disable the androidx from gradle.properties file using true --> false

    android.useAndroidX=false

    android.enableJetifier=false

    then change these lines to api v28 in build.gradle(Module:app)

    compileSdkVersion 28

    targetSdkVersion 28

    then add these line in to build.gradle(Module:app)

    `implementation 'com.android.support:appcompat-v7:28.0.0'`
    `implementation 'com.android.support:recyclerview-v7:28.0.0'`
    `implementation 'com.android.support:cardview-v7:28.0.0'`
    `implementation 'com.android.support:design:28.0.0'`
    

    Then sync the project

    0 讨论(0)
  • 2020-11-27 21:24

    I guess I can answer my own question.

    Go to File -> Import -> Existing Android code into workspace --> Browse (Go to sdk/extras/android/support/v7/cardview) --> Click ok --> Click Finish

    Your project explorer will now show cardview as a project.

    Right click on cardview project --> Properties --> Android(Left Pane) --> Enable isLibrary (tick the checkbox) --> Apply --> ok

    Now Right click on your project --> Properties --> Android(Left pane) --> Add (under library) --> cardview --> apply --> ok

    Now right click on your project again --> build path --> configure build path --> Under projects tab, add cardview

    You are done.

    0 讨论(0)
  • 2020-11-27 21:27

    If you're using VISUAL STUDIO and get this error, try restarting VS and then Rebuild Solution. That worked for me. Hopefully this saves someone some time.

    0 讨论(0)
提交回复
热议问题