0

I have been using Firebase in my Android project. Specifically: Firebase Firestore, Firebase Authentication, and Firebase Cloud Messaging.

Today I decided to add Firebase Storage to my build.gradle as I needed the storage features. Now I'm getting an error when building the project:

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:8:5-214:19 to override.

Here's my build.gradle:

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.myproject.myproject"
        minSdkVersion 23
        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(include: ['*.jar'], dir: 'libs')
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.google.firebase:firebase-core:16.0.8'
    implementation 'com.google.firebase:firebase-auth:16.2.1'
    implementation 'com.google.firebase:firebase-firestore:18.2.0'
    implementation 'com.google.firebase:firebase-messaging:17.6.0'
//    implementation 'com.google.firebase:firebase-storage:18.1.1' // this seems to be causing the error
    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:cardview-v7:28.0.0'
    implementation 'com.android.support:recyclerview-v7:28.0.0'
    implementation 'com.android.support:design:28.0.0'
    implementation 'com.android.support:support-v4:28.0.0'
    implementation 'com.journeyapps:zxing-android-embedded:3.6.0'
    implementation 'de.siegmar:fastcsv:1.0.3'
    implementation 'com.github.bumptech.glide:glide:4.9.0'

}

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

I tried adding tools:replace="android:appComponentFactory" to the <application> tag in my Manifest as the error suggested but adding it didn't fix the error.

I also like to note that only the implementation 'com.google.firebase:firebase-storage:18.1.1' dependency in my gradle is on the latest version(as of this writing).

Below Firebase dependencies are not on the latest version:

    implementation 'com.google.firebase:firebase-core:16.0.8'
    implementation 'com.google.firebase:firebase-auth:16.2.1'
    implementation 'com.google.firebase:firebase-firestore:18.2.0'
    implementation 'com.google.firebase:firebase-messaging:17.6.0'

I've already tried updating the dependencies above to the latest version and building but I still get the same Manifest merger failed error.

Anyone know how to fix this error?

fishhau
  • 459
  • 1
  • 3
  • 15

2 Answers2

2

You need to migrate to AndroidX. The version of firebase-storage that you are using requires AndroidX to work correctly, from the docs:

This release is a MAJOR version update and includes breaking changes. With this release, libraries are migrated from the Android Support Libraries to the Jetpack (AndroidX) Libraries. The updated libraries will not work unless you make the following changes in your app:

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

Also check the following link to know how to migrate:

https://developer.android.com/jetpack/androidx/migrate

Peter Haddad
  • 78,874
  • 25
  • 140
  • 134
1

They are two way to resolve this issue.

First: 1)Migrate the project in AndroidX.

Two: 1)Downgrade the fire-base dependency.

From this:-

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

implementation 'com.google.firebase:firebase-messaging:11.8.0'

Community
  • 1
  • 1
kundan kamal
  • 674
  • 7
  • 16