Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Strange CardView issue: ("Failed to find: com.android.support:cardview-v7:21.0.+" Error)

I have Android 5.0 and the most current version of the Android Support Libraries (21.0.2). I am trying to access the CardView and the RecyclerViews in Android. When I add:

compile 'com.android.support:cardview-v7:21.0.+'
compile 'com.android.support:recyclerview-v7:21.0.+'

to the app's build.gradle dependecies, I get the errors:

Failed to find: com.android.support:cardview-v7:21.0.+

and

Failed to find: com.android.support:recyclerview-v7:21.0.+

I'm not sure why this is. This is the only way I have seen people do it (and it's the way suggested on Google's website here). After this, I cannot make CardViews or RecyclerViews in my project.

I have also checked my android sdk folder:

C: > ... > android-sdk > extras > android > support > v7

and both the 'cardview' and 'recyclerview' directories are there with all the files in them.

I'm not sure why this is so... If you have any questions please ask and any suggestions or answers would be greatly appreciated!

like image 813
Bobby Avatar asked Dec 20 '22 08:12

Bobby


2 Answers

and both the 'cardview' and 'recyclerview' directories are there with all the files in them.

Those are for Eclipse.

You need to install the "Android Support Repository" in your SDK Manager:

Android Support Repository in SDK Manager

That should enable Gradle for Android to find those artifacts.

like image 167
CommonsWare Avatar answered Dec 31 '22 14:12

CommonsWare


Did you follow these steps:

I added both things android.support.v7.widget.CardView or RecyclerView as a library project and also add + check it's jar file in java build path

Go to File -> Import -> Existing Android code into workspace --> Browse (Go to sdk/extras/android/support/v7/cardview or RecyclerView) --> Click ok --> Click Finish

Right click on cardview or RecyclerView project --> Properties --> Android(Left Pane) --> Enable isLibrary (tick the checkbox) --> Apply --> ok

Right click on your project --> Properties --> Android(Left pane) --> Add (under library) --> cardview or RecyclerView --> apply --> ok

right click on your project again --> build path --> configure build path -->under libraries-->add jar-->expand cardview or RecyclerView-->expand libs-->select android.support.v7.widget.CardView.jar or RecyclerView.jar

under order and export-->check android.support.v7.widget.CardView.jar or RecyclerView.jar-->click ok

This works for me!!

like image 30
Love Garg Avatar answered Dec 31 '22 15:12

Love Garg