Pavel Malinovskij
Pavel Malinovskij

Reputation: 160

Manifest merger failed when try to connect to firebase

I am trying to connect my app with firebase so I added classpath, implementation and "apply plugin" to my graddle files enter image description here

but when I try to run an app this error occurs:

Manifest merger failed : Attribute application@appComponentFactory value=(android.sustrong textpport.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:5:5-24:19 to override.

the problem is that when I added

tools:replace="android:appComponentFactory"

in suggestions, much more errors occured. How can I solve this problem?

Here is my gradle files. Module:

    apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "lt.tetro.testapp"
        minSdkVersion 19
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.google.firebase:firebase-core:17.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'

Project:

    // Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext.kotlin_version = '1.3.10'
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.4.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        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
}

Upvotes: 0

Views: 323

Answers (2)

Oumaima Sh
Oumaima Sh

Reputation: 59

try to migrate your project to AndroidX I had the same issue and it solved it

Upvotes: 1

Peter Haddad
Peter Haddad

Reputation: 80934

firebase-core:17.0.0 is included in AndroidX, therefore update your app to use Jetpack (AndroidX).

You can check the instructions in the following link:

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

with Android Studio 3.2 and higher, you can quickly migrate an existing project to use AndroidX by selecting Refactor > Migrate to AndroidX from the menu bar.

Upvotes: 1

Related Questions