0

firstly my module build.gradle was like this:

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

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.example.depressionanalysis"
        minSdkVersion 27
        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'
        }
    }
    productFlavors {
    }
    buildToolsVersion '28.0.3'
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:28.0.0-rc02'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.android.support:design:28.0.0'
    implementation 'com.google.firebase:firebase-firestore:17.1.0'
    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.guava:guava:27.0.1-jre'
    implementation 'com.loopj.android:android-async-http:1.4.9'
}

which resulted in this warning: " The app gradle file must have a dependency on com.google.firebase:firebase-core for Firebase services to work as intended. "

so i tried to add it in (and updated firestore as well)

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

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.example.depressionanalysis"
        minSdkVersion 27
        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'
        }
    }
    productFlavors {
    }
    buildToolsVersion '28.0.3'
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:28.0.0-rc02'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.android.support:design:28.0.0'
    implementation 'com.google.firebase:firebase-firestore:21.4.2'
    implementation 'com.google.firebase:firebase-core:17.3.0'
    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.guava:guava:27.0.1-jre'
    implementation 'com.loopj.android:android-async-http:1.4.9'
}

but got 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:10:5-46:19 to override. "

How do i fix it? I've tried out a few solutions found here but to no avail.. Thanks in advance! Let me know if any other codes are needed!!

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441
miranda
  • 11
  • 2
  • See if this will help you https://stackoverflow.com/questions/51793345/android-material-and-appcompat-manifest-merger-failed – Android_id Apr 13 '20 at 15:27

3 Answers3

0

You are using the latest version of firestore:

com.google.firebase:firebase-firestore:21.4.2

and on June 2019, firebase started supporting androidX, therefore you need to migrate to androidX to be able to use firebase.

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.

Check how to migrate:

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

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

Actually, for the same library, you have different versions via different sources, You have support library as well as their AndroidX version, For Now, you can try solving it using

tools:replace="android:appComponentFactory

attribute as given in your error itself.

Go to your AndroidManifest file add this attribute like below.

<application
        android:name=".AbcApplication"      
        tools:replace="android:appComponentFactory
        >
</application>
akashzincle
  • 1,108
  • 6
  • 15
0

for me i have add two attribute in AndroidMenifest.xml

    tools:replace="android:appComponentFactory"
    android:appComponentFactory="androidx"

full tag it like :

 <application
    android:allowBackup="true"
    android:icon="@mipmap/logo"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/logo"
    android:theme="@style/AppTheme"
    tools:replace="android:appComponentFactory"
    android:appComponentFactory="androidx"
    tools:ignore="GoogleAppIndexingWarning">

and your project should be in Androidx.

Vishal Nagvadiya
  • 1,178
  • 12
  • 15