【问题标题】:android gradle error: libraries must use the exact same version specification.found version 28.0.0android gradle 错误:库必须使用完全相同的版本规范。找到版本 28.0.0
【发布时间】:2019-02-24 12:40:30
【问题描述】:

这是应用程序级别的依赖项。我一直在尝试将 firebase 添加到我的应用程序中。但它显示错误

apply plugin: 'com.android.application'  

    android {  
        compileSdkVersion 28  
        defaultConfig {  
            applicationId "com.example.rachitshah.fireapp"  
            minSdkVersion 15  
            targetSdkVersion 28  
            versionCode 1  
            versionName "1.0"  
            testInstrumentationRunner   "android.support.test.runner.AndroidJUnitRunner"  
        }
        buildTypes {
            release {
                minifyEnabled false  
                proguardFiles getDefaultProguardFile('proguard-android.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'  

这是 firebase 依赖项。

implementation 'com.google.firebase:firebase-core:16.0.1'  

【问题讨论】:

标签: android firebase gradle


【解决方案1】:

当您通过添加在 gradle 文件中添加 firebase 依赖项时

implementation 'com.google.firebase:firebase-core:16.0.1'

那么您的应用中也添加了 2 个库

com.android.support:support-media-compat:26.1.0
com.android.support:support-v4:26.1.0

它们的版本与 versin 28.0.0 不同,这就是错误发生的原因。

要修复此错误,请更改您的 gradle 文件

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'

    // Add this line
    implementation 'com.android.support:support-v4: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.1'
}

【讨论】:

  • @RachitShah 如果您的问题得到解决,那么您应该接受这个作为答案。
  • 我是怎么做到的??我的声望不够。
  • 在我的答案左侧,箭头图标下方有一个勾号图标。您只需单击它即可完成。
【解决方案2】:

看看这篇文章 android manifest merger failed, gms play services / firebase

您可能导入了一个不使用指定版本 28 的库。所以要么删除规范,要么确保它们都在同一版本上

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-05-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多