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

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.

Leave a Comment