android - 添加 firebase 时 Gradle 出现兼容性错误

标签 android gradle error-handling libraries mixing

所以,我刚刚创建了一个新项目,在添加任何新库或任何内容之前,我刚刚添加了 firebase 库,一旦我同步了 gradle,它就会给我一个错误,说混合 android 库可能会导致 appcompat 出现问题图书馆。

Image that shows the error

我在这里做错了什么?为什么我会收到此错误以及如何消除它?

这是我的 gradle 文件的源代码:

apply plugin: 'com.android.application'

    android {
        compileSdkVersion 28
        defaultConfig {
            applicationId "com.femindharamshi.codifyadmin"
            minSdkVersion 21
            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'
        implementation 'com.google.firebase:firebase-core:16.0.4'

    }

    apply plugin: 'com.google.gms.google-services'

最佳答案

您可以看到this answer 。只需要这样做:

implementation ('com.google.firebase:firebase-core:16.0.4') {
    exclude group: "com.android.support"
}

关于android - 添加 firebase 时 Gradle 出现兼容性错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53028495/

相关文章:

android - 如何在启用 "automatic"时间设置的情况下更改平板电脑的时区?

java - 如何使用正则表达式并将结果分配给 Android 中的变量?

android - 谷歌分析 Android 不工作

java - 如何从 onProgressUpdate 和 onPostExecute 获得响应

asp.net - 静态文件请求不会引发application_error事件

android - 在Android上运行React Native项目

android - 确定 Android 中其他模块的 buildType

gradle - Allure 在本地计算机上生成空的报告页面

error-handling - checkout 失败 SQLstate

flutter - 无法通过从API提取数据来获取ID