android - 如何修复:错误:无法解决:'androidx.cardview:cardview:1.0.0'
问题描述
我正在使用androidx 库开发一个新的 android 应用程序,我需要使用在我的布局中使用cardview 。
所以我尝试将cardview库添加到我的项目中,但我收到了这个错误ERROR: Failed to resolve: cardview
我检查答案Failed: com.android.support:cardview-v7:26.0.0 android
的答案,但它对我的
回答没有帮助
google()
之前添加jcenter()
- 添加
maven { url "https://maven.google.com" }
到repositories
build.gradle(项目)
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.chavosh.porterageapp"
minSdkVersion 14
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.google.android.gms:play-services-maps:16.1.0'
implementation 'androidx.appcompat:appcompat:1.1.0-alpha04'
testImplementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.material:material:1.0.0'
testImplementation 'junit:junit:4.12'
// recycler view
implementation 'androidx.recyclerview:recyclerview:1.1.0-alpha04'
implementation 'androidx.cardview:cardview:1.0.0'
}
build.gradle(模块)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.21"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
mavenCentral()
maven { url 'https://jitpack.io' }
maven { url "https://maven.google.com" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
gradle.properties 有这两行
android.useAndroidX=true
android.enableJetifier=true
解决方案
只需删除它们!
只需这 3 个,您还可以同时使用RecyclerView
andCardView
和 a plus:ConstraintLayout
implementation 'androidx.appcompat:appcompat:1.1.0-alpha04'
implementation 'androidx.core:core-ktx:1.1.0-alpha05'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
推荐阅读
- php - 获取值不是 id i datalist jquery
- css - 如何使用组件中的变量在角度样式绑定中使用 css calc()
- python - 重建计算机后 Mechanicalsoup 无法正常工作
- javascript - 如何使用 JQuery 进行闰年计算
- sql - 如何使用sql返回每篇论文的论文标题和作者数量
- ruby-on-rails - # 方法缺失或方法未定义“upsert”
- python - 将值导出到现有的 excel 文件到同一列
- arrays - livewire和laravel中的多维数组访问
- sql - 用于将whatsapp 数据传输到 SQL 或其他数据库的 ETL
- entity-framework-core - EF Core 诊断 - 每个上下文实例的查询计数