Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android cannot import RecyclerView & CardView

I'm not able to import RecyclerView & CardView although it seems very trivial. This is the relevant part from gradle.build script:

apply plugin: 'com.android.library'

android {
    compileSdkVersion 21
    buildToolsVersion "23.0.0"

    lintOptions {
        abortOnError false
    }

    defaultConfig {
        minSdkVersion 11
        targetSdkVersion 21
        versionCode 1
        versionName "1"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    sourceSets {
        main {
            java {
                srcDir 'src/main/java'
            }
            resources {
                srcDir 'src/../lib'
            }
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.0.1'
    compile 'com.android.support:cardview-v7:21.0.+'
    compile 'com.android.support:recyclerview-v7:21.0.+'
    compile 'com.google.android.gms:play-services:7.8.+'
}

The sync & build tasks executes normally so it seems that the dependencies actually downloaded. And when in some activity I try to import android.support.v7.widget.RecyclerView; it's not recognising the package.

Maybe it's SDK API versions issues? Note I need min 11 and target max 22.

like image 753
michael Avatar asked Dec 01 '22 17:12

michael


1 Answers

Add recent recyclerview which is in your sdk. 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.

Hope it will work.

like image 79
curiousMind Avatar answered Dec 04 '22 13:12

curiousMind