为什么在应用Firebase和Google身份验证库时出现清单合并错误

时间:2019-06-27 16:26:40

标签: android manifest

我正在尝试将我的应用连接到Firebase并在其中使用google身份验证系统

在应用库时,我收到清单合并错误 错误在此行

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

这是我得到的错误

ERROR: Manifest merger failed : Attribute application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91
    is also present at [androidx.core:core:1.0.0] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory).
    Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:5:5-23:19 to override.

将版本降级到16.0.0时,错误消失了,但是例如,如果我要添加,则无法添加任何其他库

implementation 'com.google.firebase:firebase-auth:18.0.0'

我收到此错误

ERROR: In project 'app' a resolved Google Play services library dependency depends on another at an exact version (e.g. "[15.0.
1]", but isn't being resolved to that version. Behavior exhibited by the library will be unknown.

Dependency failing: com.google.android.gms:play-services-stats:15.0.1 -> com.google.android.gms:play-services-basement@[
15.0.1], but play-services-basement version was 17.0.0.

The following dependencies are project dependencies that are direct or have transitive dependencies that lead to the art
ifact with the issue.
-- Project 'app' depends onto com.google.firebase:firebase-core@{strictly 16.0.0}
-- Project 'app' depends onto com.google.android.gms:play-services-flags@{strictly 17.0.0}
-- Project 'app' depends onto com.google.firebase:firebase-auth@18.0.0
-- Project 'app' depends onto com.google.firebase:firebase-core@16.0.0
-- Project 'app' depends onto com.google.firebase:firebase-analytics-impl@{strictly 16.0.0}

我是android新手,任何建议都很好

这是我的应用程序build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.example.firebasetestingprojecttwo"
        minSdkVersion 16
        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.android.support:design:28.0.0'
    implementation 'com.android.support:support-v4:28.0.0'
    implementation 'com.android.support:gridlayout-v7:28.0.0'


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

}

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

2 个答案:

答案 0 :(得分:0)

我当前正在使用以下版本。试试这个,这可能行得通。 将firebase-core版本降级为16.0.0

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

并将firebase-auth版本设置为11.6.0

implementation 'com.google.firebase:firebase-auth:11.6.0'

答案 1 :(得分:0)

要么您移民到androidX,要么将Firebase降级 例如,我使用

implementation 'com.google.firebase:firebase-messaging:17.3.4'
implementation 'com.google.firebase:firebase-core:16.0.6'`