installing repository for com.android.support.recy

2019-08-09 05:13发布

问题:

I'm a beginner in android studio and I try to use a recyclerView. When I try to add compile 'com.android.support.recyclerview-v7:21.0.+' to my gradle file, I get the error:

 failed to resolve com.android.support.receyclerview-v7v7:21.0.+.

It proposes me to install repository and sync project. when I click it, i get this error:
SDK Path C:\User\userName\AppData\Local\Android\sdk1
loading SDK information
ignoring unknown package filter 'extra-android-m2repository' warning: The package filter removed all packages. There is nothing to install. Please consider trying to update again without a package filter.
install failed, please check your network connection and try again. You may continue with creating your project, but it will not compile correctly without the missing components.  

I mention that I'm using sdk 23.0.0 on a windows system, and when installing android studio for the first time I got an error message that concern proxy (that i unfortunately skipped)!!

Any idea to solve this problem ??!!!

回答1:

First of all, run the SDK Manager and check if your support libraries repository is updated.

Then open your build.gradle (not the top level file) and add:

dependencies{

    //....
    compile 'com.android.support:recyclerview-v7:23.0.0'
}

Pay attention. You report in your question a typo in your library (compile 'com.android.support.recyclerview-v7:21.0.+')

Using the v23 you have to compile with API23.

Of course you can use a "old" version using:

 compile 'com.android.support:recyclerview-v7:22.2.1'
 compile 'com.android.support:recyclerview-v7:21.1.3'