android - 如何解决 "Inconsistencies in the existing project dependencies found"的问题?

标签 android kotlin android-recyclerview dependencies

我正在通过观看 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/

相关文章:

android - 下拉微调器仅加载列表中的第一项,然后在按下时返回 NullPointerException

android - 用于同步的空引用(监视器输入)

java - 如何在选择菜单项后启用recyclerview OnItemClickListener?

java - openCV 中的 cvtColor 创建拉伸(stretch)图像数组?

android - 在android中实现视觉反馈/忙碌指示器的最简单方法

android - Recycleview 滚动到在 Nestedscrollview 内不起作用的位置

java - 从 WorkManager 的 Work/WorkInfo 获取最后更新时间

android - 火力地堡 Firestore : Is there a callback when there is no internet connection?

java - 如何创建 RecyclerView 拖放(交换 2 个项目位置版本)

java - Viewholder的getAdapterPosition和getLayoutPosition始终为-1