user3323487
user3323487

Reputation: 61

add recyclerview and cardview dependencies to gradle module

i want to add recyclerview and cardview dependencies to gradle module but it keeps giving error : the library should not use different version(25) then compile sdk version(26) ... i have latest updated android studio sdk version 26... here is code:apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.0"
    defaultConfig {
        applicationId "com.dpl_it.m.hamzam.widgets"
        minSdkVersion 15
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:26.0.0'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:cardview-v7:25.4.0'
    compile 'com.android.support:recyclerview-v7:25.4.0'

}

Upvotes: 2

Views: 12928

Answers (5)

Ranjithkumar
Ranjithkumar

Reputation: 18406

All are old answers, here I give the newer androidX version libraries

    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'androidx.recyclerview:recyclerview:1.3.2'

I would recommended to use AndroidX libraries

Upvotes: 0

Aung Baw
Aung Baw

Reputation: 456

Reference more Creating Lists and Cards

Add following lines as dependencies in your build.gradle file (if your API is 26 or 27)

compile 'com.android.support:cardview-v7:26.1.0'
compile 'com.android.support:recyclerview-v7:26.1.0'

Upvotes: 3

Ritt
Ritt

Reputation: 3349

Your cardview and recyclerview is a part of the support library, it's version should be same as sdk version.

FYI - Your, all support library should have same version.

Check maven repository for the same.

Upvotes: 0

vignesh muthuraman
vignesh muthuraman

Reputation: 26

Use same Sdk version for all the dependencies try this compile 'com.android.support:recyclerview-v7:+' or change the sdk version to 25

Upvotes: 0

Murat Karagöz
Murat Karagöz

Reputation: 37604

Your dependency should be

compile 'com.android.support:cardview-v7:26.0.0-beta2'
compile 'com.android.support:recyclerview-v7:26.0.0-beta2'

but the support library for SDK 26 is in beta. See here for the recent notes

https://developer.android.com/topic/libraries/support-library/revisions.html

Upvotes: 4

Related Questions