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'
}
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'
}
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'
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:
Hope it helps.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.