Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SDK 5.0 RecyclerView could not be instantiated

I'm testing the new API 21, I try to create a RecyclerView but I'm stuck with a dependency problem.

The error look like that

enter image description here

my layout :

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingBottom="@dimen/activity_vertical_margin">
    <!-- A RecyclerView with some commonly used attributes -->
    <android.support.v7.widget.RecyclerView
        android:id="@+id/mRecyclerView"
        android:scrollbars="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
</RelativeLayout>

and my gradle file

apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "20.0.0"

    defaultConfig {
        applicationId "com.agonist.samplify"
        minSdkVersion 17
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:cardview-v7:+'
    compile 'com.android.support:recyclerview-v7:+'
}

I don't know what to do. I tried to clean/build the project but it stay here. Any idea ?

EDIT : Finnaly it's only an IDE preview problems. During execution everything works

like image 998
agonist_ Avatar asked Oct 19 '14 16:10

agonist_


2 Answers

The new RecyclerView does not yet work in Studio. Google are working on a fix. (Open Issue 72117)

like image 147
dsdebastiani Avatar answered Nov 20 '22 06:11

dsdebastiani


Your API and RecyclerView version should be same

Sync Gradle like :

    compileSdkVersion 23
    buildToolsVersion "23.0.1"

And

    dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        compile 'com.android.support:appcompat-v7:23.0.1'
        compile 'com.android.support:recyclerview-v7:23.0.1'
    }
like image 33
Hossein Kurd Avatar answered Nov 20 '22 06:11

Hossein Kurd