tools:replace=”appComponentFactory”
tl;dr
17 June 2019 – Dear Google release new update for Google Play service and Firebase. Out of sudden, react native application failed at compile time and keep complaining the following message.
Manifest merger failed : Attribute [email protected] 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-19:19 to override.
But, why ?
Why is it related to Google releasing new update for Google Play service and Firebase ?

Here is why. The update will required you to update your app to use Jetpack (AndroidX). Hence, you need to migrate your app to AndroidX, if you haven’t migrate yet. Android official website do provide the guide to do so – Migrating to AndroidX.
Adding the following to your gradle.properties
file in the root project folder.
For react-native project – rootProject/android/gradle.properties
android.useAndroidX=true
android.enableJetifier=true
How about React Native ?
React Native plan to support AndroidX in the next release RN 0.60. React Native June Update. So, most likely that third-party React Native library will follow afterward.
If your react native app facing any issue as describe above, I suggest a few to solve your problem.
#1 If your app use any Google API service
In your build.gradle
,
dependencies {
// Please do this
implementation "com.google.android.gms:play-services-gcm:16.1.0"
// Not this, as this line will always fetching the latest version
// implementation "com.google.android.gms:play-services-gcm:+"
}
Locked the version of Google API service, instead to taking the latest version can save you from the error. As long as your version is not the one in latest version, then you are good to go.
#2 Updating third-party React Native library
So far, what I know is that react-native-device-info is releasing a patch to fixes this issue. Maybe there is other library affected as well, that you may need to find it out.
#3 Migrating to AndroidX
But, this is not a reliable way for React Native, especially if your app depend on a huge amount of third-party library.
For more details, please refer to this github issue.
Thanks for reading. Have a nice day.