Can't use RecyclerView in my Android library project

2k views Asked by At

I have an Android library project and want to include a class that extends RecyclerView.Adapter. My build.gradle file includes the following:

apply plugin: 'com.android.library'

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

Despite this, I cannot import RecyclerView in any java file; it even does not show up in the code completions popup in Android Studio (Control+Space). What's wrong?

2

There are 2 answers

2
Anikethan Shetty On BEST ANSWER

Rebuilt the project and clean it

0
basavaraj_S On

I faced the exact same problem. Unfortunately your accepted answer did not worked for me. what i did was---- went to my library gradle file(build.gradle(Modules:youLibraryname)) and added the class path for RecyclerView. Something like this,

dependencies{ 

compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:recyclerview-v7:25.3.1'

}

Hope this helps to someone! :)