20

I want to import CardView and RecyclerView in my existing project. I am using ECLIPSE. I read other answers in stackoverflow but all of them are for Android Studio. ve Can anyone please help me ?

The error I am receiving is : CardView cannot be resolved to a type.

Update: Commonwares answer helped me solve this. But now I have another error. (Error inflating class and android.support.v7.widget.CardView). Please someone help me.

Harsh Pokharna
  • 1,121
  • 2
  • 9
  • 14
  • http://developer.android.com/tools/support-library/setup.html#add-library – tyczj Oct 21 '14 at 17:12
  • @tyczj On running the app I am getting an error. android.view.inflate exception: Error inflating class and android.support.v7.widget.CardView – Harsh Pokharna Oct 21 '14 at 17:49

6 Answers6

17

They are also available as Android library projects now, in extras/android/support/v7/ of your SDK installation. Make a copy of those projects elsewhere on your hard drive, import them into Eclipse, then reference them as libraries from your app following the instructions in the documentation.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • On running the app I am getting an error. android.view.inflate exception: Error inflating class and android.support.v7.widget.CardView – Harsh Pokharna Oct 21 '14 at 17:48
10

Currently to get the recyclerView you first download from the sdk manager the Android support repository in the 'Extras" section. After that you need to import all the libraries from here (starting from your sdk folder path):

sdk\extras\android\m2repository\com\android\support

enter image description here

j2emanue
  • 60,549
  • 65
  • 286
  • 456
  • Perfect answer. In the doc nothing that I have read notes that the recyclerview is separate from the appcompat lib. Thanks for posting! – Clocker May 06 '15 at 23:26
  • Hi. Could you explain exactly what we have to import? We have to import all of .jar files to libs? – TOP Jun 18 '15 at 02:43
6

adding android-support-v7-recyclerview.jarfrom the folder: sdk\extras\android\support\v7\recyclerview\libs to the libs resolved my problem.

Blue_Alien
  • 2,148
  • 2
  • 25
  • 29
1

For RecyclerView i am able to run by simply adding the jar file of recycler obtained from the libs folder of recycler within v7 support folder for cardview , i imported it as a android project , made it as a library and added to my project. the UI in my android worked perfect for first run but now it shows error in the UI editor but runs perfectly in emulator. hope it helps

user2779311
  • 1,688
  • 4
  • 23
  • 31
1

Finally, i resolved my problem.

.../sdk/extras/android/support/v7/

>appcompat
    >libs
        >android-support-v4.jar
        >android-support-v7-appcompat.jar
>cardview
    >libs
        >android-support-v7-cardview.jar
>gridlayout
    >libs
        >android-support-v7-gridlayout.jar
>mediarouter
    >libs
        >android-support-v7-mediarouter.jar
>palette
    >libs
        >android-support-v7-palette.jar
>recyclerview
    >libs
        >android-support-v7-recyclerview.jar

copy all jar file above to your project libs, and use this android-support-v4.jar above instead of yours

xiaoyee
  • 160
  • 7
0

add appcompat-v7.jar to your libs. This problem will be resolved.

Robert
  • 5,278
  • 43
  • 65
  • 115
thaitujim
  • 21
  • 4