【问题标题】:How to fix This "All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes)"如何解决此“所有 com.android.support 库必须使用完全相同的版本规范(混合版本可能导致运行时崩溃)”
【发布时间】:2019-06-14 07:49:29
【问题描述】:

我正在创建一个使用 firebase 身份验证进行登录和注册的应用程序,但我在运行该应用程序时不断突然崩溃。我在应用程序级别的 Gradle.build 文件中收到警告。警告说

所有 com.android.support 库必须使用完全相同的版本规范(混合版本可能导致运行时崩溃)。找到版本 28.0.0、26.1.0。示例包括 com.android.support:animated-vector-drawable:28.0.0 和 com.android.support:support-media-compat:26.1.0

我尝试将 com.android.support:appcompat-v7:28.0.0 更改为 v7:26.0.1 和 27.1.0,但都没有解决问题。

我的 build.gradle 文件如下:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.project.tck.rescueme_responder"
        minSdkVersion 14
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    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-core:16.0.6'
    implementation 'com.google.firebase:firebase-auth:16.1.0'
    implementation 'com.google.android.gms:play-services-auth:16.0.1'
}
apply plugin: 'com.google.gms.google-services'

我希望在我运行应用程序时使用 FireBase 进行身份验证,但每次运行时应用程序都会崩溃。

【问题讨论】:

  • 您是否尝试过匹配 Firebase 依赖项的版本号?示例:实施 'com.google.firebase:firebase-core:16.1.0' 实施 'com.google.firebase:firebase-auth:16.1.0'
  • 不,我没有,遗憾的是我的笔记本电脑今天被盗了,所以我必须在另一台机器上重新启动项目。但我会试一试。感谢您的贡献。

标签: java xml


【解决方案1】:

有一个类似的问题here
我想问题在于您使用的直接依赖项的传递依赖项,因为我没有看到它们在您的 build.gradle 文件中明确引用。其中一些使用一个版本 (28.0.0),而另一些 (26.1.10)。
上面引用的答案提供了一些解决方法。此外,根据您使用的 Gradle 版本(如果 >=4.6),您可以在 build.gradle 文件中 add constraints for those transitive dependencies 以确保他们使用您想要的版本。

【讨论】:

  • 我已经经历了类似的问题,它为我提供了更多的启示。不幸的是,我的笔记本电脑被盗了,所以我不得不重新启动项目。非常感谢您的回复。
  • 真的吗?!那是不幸的我的朋友。祝你重建顺利。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-07-05
  • 1970-01-01
  • 2017-11-12
相关资源
最近更新 更多