0

I'm coding an 23 API app, and i need to add Firebase Database services. When i add the line

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

in the gradle app and i try to sync, it failes showing 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 <application> element
 at AndroidManifest.xml:15:5-48:19 to override.

Can anyone please help me out?

This is my app gradle file

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28

    defaultConfig {
        applicationId "com.QUeM.TreGStore"
        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(dir: 'libs', include: ['*.jar'])
    //noinspection GradleCompatible
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'

    // Glide image library
    implementation 'com.github.bumptech.glide:glide:4.3.1'

    //dipendenza per firebase
    implementation 'com.google.firebase:firebase-core:11.8.0'
    implementation 'com.google.firebase:firebase-database:18.0.0'

    implementation 'com.android.support:design:28.0.0'
    implementation 'com.android.support:support-annotations:28.0.0'
    implementation 'android.arch.lifecycle:extensions:1.1.1'

    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.google.android.gms:play-services-vision:11.8.0'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'

}

//plugin per l'utilizzo di firebase
apply plugin: 'com.google.gms.google-services'
Peter Haddad
  • 78,874
  • 25
  • 140
  • 134
  • by migration to androidx or by using older firebase version(compatible with support library) – Selvin Jul 12 '19 at 10:24
  • i don't know what migrating to androidX would involve to my app, but i'd stick with the current structure. I'll try a older version, thank you. – ilpeppone7 Jul 13 '19 at 14:08

1 Answers1

2

If you want to use implementation 'com.google.firebase:firebase-database:18.0.0 then you have to do the following:

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:

  • 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.

To migrate the other dependencies to androidx package, you can do the following:

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.

Check this for more info:

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

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