1

I want to connect my Android Studio with firebase. I follow steps on firebase website but when i put a code:

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

An error it comes:

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-20:19 to override.

When I use that first line like a comment the error it disappear!

 buildscript {
  repositories {
    google()
    jcenter()

  }
 dependencies {
     classpath 'com.android.tools.build:gradle:3.4.1'
     classpath 'com.google.gms:google-services:4.2.0'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
  }
  }

 allprojects {
    repositories {
      google()
      jcenter()

   }
  }

  task clean(type: Delete) {
     delete rootProject.buildDir
   }

Second File

apply plugin: 'com.android.application'

android {
  compileSdkVersion 28
  defaultConfig {
    applicationId "com.example.rentacar"
    minSdkVersion 28
    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 'com.google.firebase:firebase-core:17.0.0'
   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'

  }
 apply plugin: 'com.google.gms.google-services'
Toni
  • 15
  • 6
  • Can you post your manifest please – Anupam Jul 04 '19 at 03:37
  • 1
    Possible duplicate of [Manifest merger failed after adding Firebase core version 17.0.0](https://stackoverflow.com/questions/56839238/manifest-merger-failed-after-adding-firebase-core-version-17-0-0) – sanoJ Jul 04 '19 at 04:38

3 Answers3

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

This version of firbase library uses AndroidX architecture components.

If you are not using any of AndroidX architecture components in your project then downgrade your firebase sdk version to 16.0.9.

implementation 'com.google.firebase:firebase-core:16.0.9'
DHAVAL A.
  • 2,251
  • 2
  • 12
  • 27
1
android.useAndroidX=true
android.enableJetifier=true

Add this two line in gradle.properties.

Pankaj Savaliya
  • 141
  • 1
  • 2
  • 11
0

All you need to do is migrate your app to AndroidX if you are using lastest firebase SDK. Google says :

In June 2019, all the Firebase SDKs for Android 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: 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.

Those are the steps to migrate:

Click on refactor in the top menu -> refactor this -> Migrate to AndroidX

I have added the screenshots to make it easier. enter image description here

enter image description here

Hope it helps

sidibe
  • 51
  • 5