【问题标题】:how to solve the problem of "Inconsistencies in the existing project dependencies found"?如何解决“发现现有项目依赖项不一致”的问题?
【发布时间】:2020-02-10 09:48:16
【问题描述】:

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

添加此库后项目可能无法编译。 还是要添加吗?”

如果我选择“确定”并继续,预览屏幕将变为灰色。

我应该怎么做才能解决这个问题?

当我想在xml文件中添加cardview时也会出现同样的问题。

提前谢谢!!!!

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'
}

【问题讨论】:

  • 我已经解决了我的问题。让我分享一下,看看是否有用。 holland.pk/uptow/i4/fb987a06a34375218dd7be723d6b8661.jpg 请看上面链接中的图片。感叹号标有红色圆圈。在添加recyclerview并生成灰色预览屏幕后,单击该感叹号并按照消息框中的说明进行操作。问题将得到解决。回收站视图可以正常显示。

标签: android kotlin android-recyclerview dependencies


【解决方案1】:

只需重新构建项目并手动刷新布局即可。 :)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-11-07
    • 2011-02-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-24
    相关资源
    最近更新 更多