It's been a while I'm trying to run/code a RecyclerView example, with no success though. I guess it has something to do with the RecyclerView version used in dependencies and the Android versions my project is using. Currently, I'm trying to run this example here.
It doesn't mention what are the compileSdkVersion, minSdkVersion and so on. Anyway, here's my gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.example.deluxe.example"
minSdkVersion 24
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.android.support:recyclerview-v7:28.0.0-rc01'
implementation 'com.squareup.picasso:picasso:2.5.2'
}
Also in this example, the Adapter imports android.support.v7.widget.RecyclerView, for which I get an error: Cannot resolve symbol v7. So, Android suggested importing androidx.recyclerview.widget.RecyclerView;
Issue: my project doesn't load the RecyclerView in the MainActivity - it throws an exception: Error inflating class android.support.v7.widget.RecyclerView for which although there're similar questions here and here and here, I couldn't solve my issue.
I'm new to Android Studio, so can anyone suggest what should I change in order to run this Recycler/CardView example? I've tried several examples already, but wasn't able to run any of them - recent and older ones. I'm trying to run using Android Nougat(7.0) and upper, but it's not mandatory. And my Android Studio version is 3.5.1