android - 在 Android Studio 中更新外部库

标签 android android-gradle-plugin build.gradle

我是 Android 开发的新手,如果这很明显,我深表歉意。我进行了很多搜索,但无法解决我的问题。

在我的 build.gradle 文件中有以下部分:

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.0'
    implementation 'com.android.support:design:26.1.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'com.google.firebase:firebase-auth:15.1.0'
    implementation 'com.google.android.gms:play-services-auth:15.0.1'
    implementation 'com.wdullaer:materialdatetimepicker:3.2.2'
}

然而,行 implementation 'com.android.support:appcompat-v7:26.1.0' 下方显示红色波浪线并显示以下消息:

All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 26.1.0, 25.3.1. Examples include com.android.support:animated-vector-drawable:26.1.0 and com.android.support:support-v13:25.3.1 less... (⌘F1)

There are some combinations of libraries, or tools and libraries, that are incompatible, or can lead to bugs. One such incompatibility is compiling with a version of the Android support libraries that is not the latest version (or in particular, a version lower than your targetSdkVersion).

我无法找到解决此问题的方法。构建项目工作正常,不报告任何错误。我试过执行 File > Invalidate Caches/Restart 但无济于事。

在做了一些搜索后,我读到我可以将 implementation 'com.android.support:support-v4:26.1.0' 添加到 build.gradle 文件中,它应该可以修复它,但是,即使在同步后也会出现相同的错误。

这是我去年某个时候做的一个旧项目,里面的内容不多,但我认为最好学习如何解决这个问题,而不是仅仅创建一个新项目来解决它。

最佳答案

尝试添加

实现'com.android.support:support-v13:26.1.0'

关于android - 在 Android Studio 中更新外部库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50351242/

相关文章:

android - SelectableItemBackground 没有涟漪效应

php - 数据同步如何工作以及如何在服务器-客户端应用程序中使用它?

android - 如何以编程方式设置 android :button ="@null"?

android - 软键盘不会在 android 中以编程方式隐藏

android - 意外的资源引用类型

android - 构建 gradle 需要很长时间(8 分钟到 20 分钟)

android - java.lang.IncompatibleClassChangeError 导致应用程序崩溃,使用 Firebase 和 Google Play 服务

Android Studio-Gradle : How to replace variables in a file

java - 布局预览中的 TextClock 渲染问题

android - 没有足够的信息来推断类型变量 T