Search code examples
androidfirebase-authenticationandroid-manifestmanifest-merging

Manifest merger Failed after adding Google Firebase Authentication


After adding Firebase Authentication to app implementation I got a Manifest Merger failed error.

"Manifest merger failed with multiple errors, see logs"

I tried using different versions of the authentication but didn't work. The solutions for the same type of problems in StackOverflow didn't work for me.

I tried the suggested changes in Merged manifest but this error came up again

Merging Errors: Error: tools:replace specified at line:6 for attribute android:appComponentFactory, but no new value specified app main manifest (this file), line 5 Error: Validation failed, exiting app main manifest (this file)

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme"
        tools:replace="android:appComponentFactory">
        <activity android:name=".VerifyEmployeeID"></activity>
        <activity android:name=".SignUp" />
        <activity android:name=".login" />
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'


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

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

    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'

I need to get rid of this error.


Solution

  • This happens because you are using simple dependency or androidx support dependency. That's why this error occurs.

    Remove below the line in Manifest.xml

    tools:replace="android:appComponentFactory"

    Use this dependency in build.gradle

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

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

    Remove all androidx dependency in your build.gradle file and sync project.