Reputation: 359
While learning about RecyclerView, I am facing some problem. GreenAdapter Class failed to import “android.support.v7.widget.RecyclerView”. I am using Android Studio 3.1.4. My compile SDK Version is 28. Here's my build.gradle File:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.sunshine.sunshine.app"
minSdkVersion 17
targetSdkVersion 28
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation project(':sunshinemodule')
implementation project(':base')
implementation 'com.android.support:design:28.0.0-rc01'
}
I am also sharing the code where the import is not working:
Upvotes: 2
Views: 5341
Reputation: 75788
You should add
implementation 'com.android.support:recyclerview-v7:27.1.1' //28.0.0-rc01
After that, Clean-rebuild
and Run
.
Upvotes: 1
Reputation: 2393
Right click on app --> Open Module Settings --> Dependencies then on right side click on plus button. Add library dependency and search recyclerview and then add it.
Upvotes: 0
Reputation:
Add this to your gradle:
implementation 'com.android.support:recyclerview-v7:28.0.0-rc01'
implementation 'com.android.support:appcompat-v7:28.0.0-rc01'
and then click "Sync now".
Upvotes: 1