我正在通过观看 youtube 上的一些教程来学习编写 android 应用程序。我按照教程并尝试在 xml 文件中添加 recyclerview。当我单击 recyclerview 旁边的下载按钮时,会显示以下消息:
“此操作需要库 androidx.recyclerview:recyclerview:+。
问题:发现现有项目依赖项中的不一致。
之间的版本不兼容:
- androidx.appcompat:appcompat:1.1.0@aar
和:
- androidx.core:core-ktx:1.1.0@aar
依赖:
- androidx.annotation::1.1.0
相对:
- androidx.annotation::2.0.0
添加此库后,项目可能无法编译。
还是要添加吗?”
如果我选择 OK 并继续,预览屏幕将变为灰色。
我应该怎么做才能解决问题?
当我想在 xml 文件中添加卡片 View 时,也会出现同样的问题。
提前致谢!!!!
build.gradle 如下:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.smartherd.msgshareapp"
minSdkVersion 21
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
最佳答案
只需再次构建项目并手动刷新布局。 :)
关于android - 如何解决 "Inconsistencies in the existing project dependencies found"的问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58365429/