problem with gradle dependencies - recyclerview and cardview

androidx recyclerview dependency
androidx cardview gradle

I am trying to implement cardview and recyclerview. But I am getting this error

Failed to resolve: com.android.support:cardview-v7:21.1.1 Show in File Show in Project Structure dialog

Failed to resolve: com.android.support:recyclerview-v7:21.1.1 Show in File Show in Project Structure dialog

this is my dependencies

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

First of all use the latest implementation dependency prefix instead of the obsolete compile configuration for all your dependencies. Second try to use the latest dependencies which as of now is 27.1.1 (stable). And about the Gradle build error, there must be a connection failure which usually caused by an interrupted internet connection or working with Gradle on offline mode and etc.

Try to check these options to troubleshoot:

  1. Open Android Studio settings (Ctrl + Alt + S on Windows) and type HTTP Proxy on the search field then select the setting from left menu and use the Check connection button with some google repository address like https://dl.google.com/android/repository/repository-12.xml and wait for a Connection successful message, anything else means your proxy or internet connection is somehow the culprit and you need to seek there for a solution.
  2. Make sure you're not using Gradle in offline mode which can be done in Settings> Build, Execution, Deployment> Gradle and the "Offline work" check must be off.

Hope it helps.

problem with gradle dependencies, I am trying to implement cardview and recyclerview. But I am getting this error. Failed to resolve: com.android.support:cardview-v7:21.1.1 Show  [sociallocker]Download Recyclerview_cardview [/sociallocker] Step 1: Create a new project in Android Studio. Make a new android studio project with empty activity. Step 2: Updating build.gradle(Module:app) file. Add below source code into dependencies{}

Though it could be version conflicts with appcompat lib.

But, Update your Target APIs to Android 8... see here.

https://developer.android.com/distribute/best-practices/develop/target-sdk

So, your gradle file should look like this.

apply plugin: 'com.android.application'

repositories {
    maven {
        url "https://jitpack.io"
    }
    mavenCentral()
}

android {
    compileSdkVersion 28
    buildToolsVersion '28.0.2'

    defaultConfig {
        applicationId "your.package"
        minSdkVersion 16
        targetSdkVersion 28
        versionCode = code
        versionName = "ver name"
    }

    buildTypes {
        release {
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}


dependencies {
    implementation 'com.android.support:support-v4:28.0.0-rc02'
    implementation 'com.android.support:appcompat-v7:28.0.0-rc02'
    implementation 'com.android.support:design:28.0.0-rc02'
    implementation 'com.android.support:cardview-v7:28.0.0-rc02'
    implementation 'com.android.support:recyclerview-v7:28.0.0-rc02'
}

Cardview, Declaring dependencies. To add a dependency on CardView, you must add the Google Maven repository to your project. Read Google's  Dismiss Join GitHub today. GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.

Its because of incorrect version.

implementation 'com.android.support:appcompat-v7:21.0.3' //same as other support library vesion you used.
implementation 'com.android.support:cardview-v7:21.0.3'
implementation 'com.android.support:recyclerview-v7:21.0.3'
implementation 'com.android.support:design:21.0.3'

Recyclerview, Add the dependencies for the artifacts you need in the build.gradle file for your Fixed an issue where RecyclerView was generating duplicate  To add a dependency on RecyclerView, you must add the Google Maven repository to your project. Read Google's Maven repository for more information. Add the dependencies for the artifacts you need in the build.gradle file for your app or module: For more information about dependencies, see Add build dependencies.

#3.2 Android Integrate RecyclerView and CardView Dependency in , Learn to integrate RecyclerView and CardView in layout ( user interface ), first by adding their Duration: 4:40 Posted: May 29, 2018 Declaring dependencies. To add a dependency on CardView, you must add the Google Maven repository to your project. Read Google's Maven repository for more information. Add the dependencies for the artifacts you need in the build.gradle file for your app or module: dependencies { implementation "androidx.cardview:cardview:1.0.0" }

Integrate RecyclerView and CardView Dependency in Gradle , Learn to integrate RecyclerView and CardView in layout ( user their Gradle dependencies in Duration: 6:32 Posted: Nov 3, 2018 The Gradle build script dependency identifier for this library is as follows: com.android.support:support-core-ui:28.0.0 v4 media-compat library. Backports portions of the media framework, including MediaBrowser and MediaSession. The Gradle build script dependency identifier for this library is as follows:

Update gradle, sdk and dependencies · Issue #13 · googlecodelabs , I was able to fix the problem by changing in my build.gradle file: compile 'com.​android.support:recyclerview-v7:26.0.0-alpha1' to compile  Sebelum kita mulai membuatnya, mari kita pahami dahulu apa itu sebenarnya RecyclerView dan CardView. Pertama kita tambahkan dependencies dalam gradle, lalu lakukan Sync Now.

Comments
  • Try to use latest implementation 'com.android.support:design:27.1.1' implementation 'com.android.support:recyclerview-v7:27.1.1' implementation 'com.android.support:cardview-v7:27.1.1'
  • Please use same version of com.android.support libs.