Material-components-android: Unable to use Material Card view

Created on 26 Feb 2018  路  6Comments  路  Source: material-components/material-components-android

Hi,

I have been trying to add material card view to my preoject. When I add as shown in documentation, it shows class not found exception. I have the below dependencies in my build.gradle. Can you help me

implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
compile "com.android.support:appcompat-v7:26.1.0"
compile 'com.android.support:design:26.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:0.5'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:2.2.2'
implementation 'com.android.support:cardview-v7:26.1.0'

Most helpful comment

You need to use version 28.0.0-alpha1

All 6 comments

I've got the same issue. Did you find any solution?

No I havent. I started using Native android material view

You need to use version 28.0.0-alpha1

That's true, but so it should be better to tell that in docs. Ain't it?

apply plugin: 'com.android.application'

android {
    compileSdkVersion 'android-P'
    buildToolsVersion '28.0.0-rc1'
    defaultConfig {
        applicationId "com.example.xxx.materialcardviewtest"
        minSdkVersion 19
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0-alpha1'
    implementation 'com.android.support:design:28.0.0-alpha1'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}

mdc-android

Gah! I've just spent two hours trying to work out what I did wrong, and this is the answer. Update to P (28). The docs really need to say this.

Was this page helpful?
0 / 5 - 0 ratings