has*_*had 0 android gradle cardview androidx
我正在使用androidx库开发一个新的android应用程序,并且需要在布局中使用cardview。
所以我尝试将cardview库添加到我的项目中,但出现此错误ERROR: Failed to resolve: cardview
我检查的答案失败:com.android.support:cardview-v7:26.0.0机器人,但它并不能帮助我
回答像
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'
}
Run Code Online (Sandbox Code Playgroud)
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
}
Run Code Online (Sandbox Code Playgroud)
gradle.properties有这两行
android.useAndroidX=true
android.enableJetifier=true
Run Code Online (Sandbox Code Playgroud)
只需删除它们!
只需这3个可以同时使用RecyclerView,并CardView与加还有: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'
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4847 次 |
| 最近记录: |