Manifest merger failed with Firebase Auth

2020-06-25 04:50发布

问题:

When I implement

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

The Manifest not Sync, Error message like this:

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 element at AndroidManifest.xml:7:5-25:19 to override.

My manifest doc:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.gokhanyilmaz.appseriestracker"
        minSdkVersion 21
        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'
    implementation 'com.android.support:design:28.0.0'
    implementation 'com.android.support:cardview-v7:28.0.0'
    implementation 'com.squareup.picasso:picasso:2.71828'
    implementation 'com.google.firebase:firebase-core:17.0.0'
    implementation 'com.google.firebase:firebase-auth:18.0.0'
    implementation 'com.google.android.gms:play-services-auth:17.0.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'
}
apply plugin: 'com.google.gms.google-services'

回答1:

I just got the same problem like you. And this is how I solve it. You can try it: (i'm using newest android version of 2019) I change this:

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

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

into this:

 implementation 'com.google.firebase:firebase-core:16.0.5'
implementation 'com.google.firebase:firebase-auth:16.0.5'

and if you you want to implement firebase database. I think we should you this:

implementation 'com.google.firebase:firebase-database:16.0.4'

Instead of following introduction on Firebase Documentation. Hope it work for you



回答2:

Firebase migrated to AndroidX in the latest release. It means that you are using both, support libraries and androidx libraries.

You can:

  • migrate to androidx as described below
  • downgrade your firebase dependencies (but it is not a real solution because you have to migrate before or after)

You can check the official release notes:

Warning: This release is a MAJOR version update and breaking change. The latest update to Google Play services and Firebase includes the following changes:

Migration from Android Support Libraries to Jetpack (AndroidX) Libraries. Libraries will not work unless you make the following changes in your app:

  • Upgrade com.android.tools.build:gradle to v3.2.1 or later.
  • Upgrade compileSdkVersion to 28 or later.
  • Update your app to use Jetpack (AndroidX); follow the instructions in Migrating to AndroidX.


回答3:

You firebase versions are incompatible. You can check the latest releases for compatibility or you can use this

implementation 'com.google.firebase:firebase-firestore:19.0.2'
implementation 'com.google.firebase:firebase-auth:17.0.0'