How do I add Android Support v7 libraries in eclipse? For example how do I add CardView to an eclipse android project?
Note: This was a self answer question, so no need to waste your time making an answer. Of course, if you have anything to add, please do.
In the Properties window, select the "Android" properties group at left and locate the Library properties at right. Select /path/to/appcompat/ and Click Remove. Click Add to open the Project Selection dialog. From the list of available library projects, select v7 appcompat library and click OK.
difference. v4 has largest set of API's than others like App component, User Interface Feature, data handling ,network connectivity and utilities. v7 provided specfic feature sets that can be included in your app independently.
Android AppCompat Library V7 The Support Library is a static library that you can add to your Android application in order to use APIs that are either not available for older platform versions or utility APIs that aren't a part of the framework APIs. Compatible on devices running API 14 or later. License.
The Android Support Library package is a set of code libraries that provide backward-compatible versions of Android framework APIs as well as features that are only available through the library APIs. Each Support Library is backward-compatible to a specific Android API level.
From: https://developer.android.com/tools/support-library/setup.html#libs-with-res
I know this looks like a lot of steps, but in reality it's just very broken down and only takes two minutes
To add a Support Library with resources (such as v7 cardview) 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 cardview
project, browse to <sdk>/extras/android/support/v7/cardview/
.
Click Finish to import the project. For the v7 cardview project, you should now see a new project titled android-support-v7-cardview
.
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 v7 cardview project, add the android-support-v7-cardview.jar
file to the build path. (Depending on your setup, Eclipse may have done this four you already.)
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 cardview project requires you to export the android-support-v7-cardview.jar
file. (Depending on your setup, Eclipse may have done this four you already.)
Uncheck Android Dependencies.
Click OK (or Apply and Close) 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.
Now 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-cardview
.
In the properties window, click OK (or Apply and Close).
For some libraries, you will get error messages such as
No resource found that matches the given name 'android:Widget.Material.ActionButton'. styles_base.xml/appcompat_v7/res/values-v21
If that happens, record the highest API level you are seeing in those error messages (v21 in the example above). Then, in the properties of your library project, go to Android and set the target API to that level (or a higher one), then clean your projects.
This is what worked for me. (Using the same CardView example from above)
(Android SDK Install Location) > extras > android > support > v7 > cardview
Now the library is imported.
PS: I tried I'm_With_Stupid's answer, and while trying to add the library project to my project, it was not listed there.
I did not have to uncheck Android Dependencies, etc. It might work in some other situation, I guess.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With