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

I'd like to use the new CardView widget that was introduced with the new Android L Developer Preview Support Library (As mentioned here), which seems to be part of a new revision of the v7 support library.

I have now updated my SDK version, downloaded the newest Support Library package, but I still cannot find the new CardView widget.

I already searched the web and the official docs, but could not get any hints on where I can get the new support library.

Any help is highly appreciated!

EDIT: I'm using ADT/Eclipse

The answer is


Simply add the following line in your build.gradle project

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

And sync the project with gradle.


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 action bar) to your application project:

Using Eclipse

Create a library project based on the support library code:

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

  • Create a library project and ensure the required JAR files are included in the project's build path:

  • Select File > Import.

  • Select Existing Android Code Into Workspace and click Next.

  • Browse to the SDK installation directory and then to the Support Library folder. For example, if you are adding the appcompat project, browse to /extras/android/support/v7/appcompat/.

  • Click Finish to import the project. For the v7 appcompat project, you should now see a new project titled 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 the the v7 appcompat project, add both 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.

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

  • Uncheck Android Dependencies.

  • Click OK to complete the changes.

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

  • Add the library to your application project:

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

  • In the category panel on the left side of the dialog, select Android.

  • In the Library pane, click the Add button.

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

  • In the properties window, click OK.


https://github.com/yongjhih/CardView

A CardView v7 eclipse project. (from sdk/extras/android/m2repository/com/android/support/cardview-v7)

The project was built by steps:

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

Maybe it's a little bit late to add answer here. But I think this answer will help the later ones and especially those who don't want to use Android Studio.

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

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


In the most latest android, we implement card view like this:

build.gradle file:

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

and in the xml file its referenced as:

<androidx.cardview.widget.CardView
…>
…
</androidx.cardview.widget.CardView>

this means its class has changed to: androidx.cardview.widget.CardView


I was able to work it out only after adding those two TOGETHER:

dependencies {
...
implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation 'com.android.support:cardview-v7:27.1.1'
...
}

in my build.gradle (Module:app) file

and then press the sync now button


I have done following and it resolve an issue with recyclerview same you may use for other widget as well if it's not working in eclipse project.

• Go to sdk\extras\android\m2repository\com\android\support\recyclerview-v7\21.0.0-rc1 directory

• Copy recyclerview-v7-21.0.0-rc1.aar file and rename it as .zip

• Unzip the file, you will get classes.jar (rename the jar file more meaningful name)

• Use the following jar in your project build path or lib directory.

and it resolve your error.

happy coding :)


You need to add this in your build.gradle:

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

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


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

There does not seem to be a regular Android library project at this time for cardview-v7, leanback-v17, palette-v7, or recyclerview-v7. I have no idea if/when Google will ship such library projects.


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

If you really want to use CardView before in eclipse before it gets its own library, you can extract the classes from the classes.jar, copy and paste them into your project, with the values.xml from above from Android Studio and change all the references to android.support.v7.R to yourpackagename.R in the copied classes. This worked and ran for me


Although a bit hidden it's in the official docs here where can the library be found among the sdk's code, and how to get it with resources (the Eclipse way)


Examples related to android

Under what circumstances can I call findViewById with an Options Menu / Action Bar item? How to implement a simple scenario the OO way My eclipse won't open, i download the bundle pack it keeps saying error log getting " (1) no such column: _id10 " error java doesn't run if structure inside of onclick listener Cannot retrieve string(s) from preferences (settings) strange error in my Animation Drawable how to put image in a bundle and pass it to another activity FragmentActivity to Fragment A failure occurred while executing com.android.build.gradle.internal.tasks

Examples related to eclipse

How do I get the command-line for an Eclipse run configuration? My eclipse won't open, i download the bundle pack it keeps saying error log strange error in my Animation Drawable How to uninstall Eclipse? How to resolve Unable to load authentication plugin 'caching_sha2_password' issue Class has been compiled by a more recent version of the Java Environment Eclipse No tests found using JUnit 5 caused by NoClassDefFoundError for LauncherFactory How to downgrade Java from 9 to 8 on a MACOS. Eclipse is not running with Java 9 "The POM for ... is missing, no dependency information available" even though it exists in Maven Repository The origin server did not find a current representation for the target resource or is not willing to disclose that one exists. on deploying to tomcat

Examples related to android-5.0-lollipop

Android changing Floating Action Button color Android Support Design TabLayout: Gravity Center and Mode Scrollable Android statusbar icons color Notification bar icon turns white in Android 5 Lollipop How can I change default dialog button text color in android 5 Lollipop : draw behind statusBar with its color set to transparent Android lollipop change navigation bar color CardView not showing Shadow in Android L App crashing when trying to use RecyclerView on android 5.0 How to change status bar color to match app in Lollipop? [Android]

Examples related to android-cardview

CardView background color always white Margin between items in recycler view Android How to add colored border on cardview? How to add a recyclerView inside another recyclerView CardView Corner Radius CardView not showing Shadow in Android L RecyclerView inside ScrollView is not working Ripple effect on Android Lollipop CardView How do I get the position selected in a RecyclerView? Change the background color of CardView programmatically