Using android.support.v7.widget.CardView in my project (Eclipse)

I would like to use the new CardView widget that was introduced in the new Android L preview support library (as mentioned here ), which seems to be part of the new version of the v7 support library.

Now I updated the SDK version, downloaded the latest Support Library, but I still can’t find the new CardView widget.

I already searched the Internet and white papers, but couldn't figure out where I could get the new support library.

Any help is much appreciated!

EDIT: I am using ADT / Eclipse

+54
android eclipse android-5.0-lollipop android-cardview
Jun 27 '14 at 10:13
source share
11 answers

I finally found a way to use CardView in ADT / Eclipse. This is actually pretty easy:

  • Create a new project in Android Studio
  • Add a CardView dependency as described in other answers to this question.
  • Open ADT and create a new library project with the package name android.support.v7.cardview
  • Delete all resources created by ADT automatically
  • Find the exploded-aar in Android Studio and copy the following files to these places:
    • res / values ​​/values.xml in the same place in your ADT project
    • classes.jar in libs / in your ADT project
    • AndroidManifest.xml uses it to replace an auto-generated manifest in ADT
  • Add classes.jar to the build path and make sure it is exported
  • Add a link to the library project in the project in which you want to use CardView. You can follow the steps outlined in Adding libraries with resources here: https://developer.android.com/tools/support-library/setup.html

As an alternative to creating a new Android Studio project, to get the AAR content, you can also just find and unzip the AAR from the local maven repository. Just follow the instructions given by Andrew Chen below.

Please note that the CardView library may not be available in a version and ADT compatible format, as it is still only a preview and WIP. Since bugs and improvements can be fixed in future releases, it is important to keep the updated library, which is easy with the Gradle dependency, but must be done manually using the steps above.

+40
Jun 28 '14 at 15:07
source share
β€” -

Using Gradle or Android Studio, try adding a dependency on com.android.support:cardview-v7:21.+ .

There is currently no regular Android library project for cardview-v7 , leanback-v17 , palette-v7 or recyclerview-v7 . I do not know when / when Google will submit such library projects.

+49
Jun 27 '14 at 10:27
source share

You need to add this to your build.gradle:

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

And then Sync Project with Gradle Files . Finally, you can use CardView as described here .

+27
Jun 27 '14 at 10:29
source share

I followed these steps and resolved a recyclerview problem that you can use for another widget if it does not work in an eclipse project.

β€’ Go to the sdk \ extras \ android \ m2repository \ com \ android \ support \ recyclerview-v7 \ 21.0.0-rc1 directory

β€’ Copy the file recyclerview-v7-21.0.0-rc1.aar and rename it as .zip

β€’ Unzip the file, you will get classes.jar (rename the jar file with a more meaningful name)

β€’ Use the following jar in the project creation path or in the lib directory.

and it will fix your mistake.

happy coding :)

+27
Jul 02 '14 at 21:08
source share

https://github.com/yongjhih/CardView

Eclipse CardView v7 Project. (from sdk / extras / android / m2repository / com / android / support / cardview-v7)

The project was created in stages:

 cp {sdk}/extras/android/m2repository/com/android/support/cardview-v7/21.0.0-rc1/cardview-v7-21.0.0-rc1.aar cardview-v7-21.0.0-rc1.zip unzip cardview-v7-21.0.0-rc1.zip mkdir libs/ mv classes.jar libs/cardview-v7-21.0.0-rc1.jar 
+19
Jul 02 '14 at 3:40
source share

I was able to process it only after adding these two TOGETHER:

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

in the build.gradle file (Module: app)

and then click the sync button now

+4
Nov 20 '16 at 10:54 on
source share

Although I hid it a bit in official white papers , where you can find the library among the sdk code and how to get it using resources (Eclipse path)

+3
Nov 05 '14 at
source share

From: https://developer.android.com/tools/support-library/setup.html#libs-with-res

Adding libraries with resources To add a support library with resources (such as v7 appcompat for the action bar) to the application project:

Using Eclipse

Create a library project based on the support library code:

  • Make sure you download the Android Support Library using the SDK Manager.

  • Create a library project and verify that the necessary JAR files are included in the project build path:

  • Choose File> Import.

  • Select an existing Android code in the workspace and click Next.

  • Go to the SDK installation directory and then to the Support Library folder. For example, if you are adding an appcompat project, go to / extras / android / support / v 7 / appcompat /.

  • Click Finish to import the project. For the v7 appcompat project, you should see a new project called android-support-v7-appcompat.

  • In the new library project, expand the libs / folder, right-click each .jar file and select Build

  • Path> Add to build path. For example, when creating a v7 appcompat project, add the android-support-v4.jar and android-support-v7-appcompat.jar files to the build path.

  • Right-click the library project folder and select Build Path> Configure Build Path.

  • On the Order and Export tab, check the .jar files that you just added to the build path, so they are available for projects that depend on this library project. For example, for the appcompat project, you need to export the android-support-v4.jar and android-support-v7-appcompat.jar files.

  • Uncheck the Android Dependencies box.

  • Click OK to complete the changes.

  • You now have a library project for your support library that you can use with one or more application projects.

  • Add the library to your application project:

  • In Project Explorer, right-click the project and select Properties.

  • In the categories pane on the left side of the dialog box, select Android.

  • In the Library panel, click the Add button.

  • Select a library project and click OK. For example, the appcompat project should be listed as support android-support-v7-appcompat.

  • In the properties window, click OK.

+2
Nov 12 '14 at 3:01
source share

Maybe a little late to add an answer here. But I think this answer will help later and especially those who do not want to use Android Studio.

Although the docs indicate that RecyclerView and CardView are part of the appcompat v7 library. But as I tried and found, RecyclerView and CardView actually depend on the v7 appcompat library. Therefore, if you want to use RecyclerView or CardView, you need to add both v7 appcompat library and RecyclerView / CardView.

Link to link here , if you want to use CardView in an Eclipse android project, you need to import both the appcompat v7 library and CardView into Eclipse and make them as library projects. Then the CardView project will depend on the v7 appcompat library project and make your project depend on the CardView project.

+2
Jun 24 '15 at 9:00
source share

Just add the following line to your build.gradle project

 dependencies { ... compile 'com.android.support:cardview-v7:24.0.0' } 

And sync the project with gradle.

+2
Apr 6 '16 at 5:29
source share

I did what FD_ said, and it crashed with errors because I was looking for "Landroid / support / v7 / cardview / R $ styleable;" which was not compiled with it

If you really want to use CardView earlier than in eclipse, before it gets its own library, you can extract the classes from classes.jar, copy and paste them into your project using value.xml at the top of Android Studio and change all the links to android.support.v7.R on yourpackagename.R in copied classes. It worked and ran for me.

0
Jun 28 '14 at 19:57
source share



All Articles