1

Running my app got this error:

Manifest merger failed : Attribute application@appComponentFactory value=(androidx.core.app.CoreComponentFactory) from [androidx.core:core:1.0.0] AndroidManifest.xml:22:18-86
        is also present at [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91 value=(android.support.v4.app.CoreComponentFactory).
        Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:7:5-117 to override.

I've tried to add to gradle.properties

android.useAndroidX=true
android.enableJetifier=true

and also (to AndroidManifest)

tools:replace="android:appComponentFactory"
android:appComponentFactory="whateverString"

and also (to build.gradle)

implementation "androidx.appcompat:appcompat:1.0.0"

replacing the previous

implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"

but not working for me.

-- Android Manifest.xml --

<uses-permission android:name="android.permission.INTERNET" />

<application
  android:name=".MainApplication"
  android:label="@string/app_name"
  android:icon="@mipmap/ic_launcher"
  android:roundIcon="@mipmap/ic_launcher_round"
  android:allowBackup="false"
  android:theme="@style/AppTheme">
  <activity
    android:name=".MainActivity"
    android:label="@string/app_name"
    android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
    android:windowSoftInputMode="adjustResize">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
  </activity>
  <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
</application>

-- build.gradle --

dependencies {
    implementation project(':react-native-exit-app')
    implementation project(':react-native-firebase')
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "com.android.support:appcompatv7:
 ${rootProject.ext.supportLibVersion}"
    implementation "com.facebook.react:react-native:+"  // From node_modules
    implementation "com.google.android.gms:play-services-base:16.1.0"
    implementation "com.google.firebase:firebase-core:17.0.0"
    implementation 'com.google.firebase:firebase-auth:18.0.0'
    implementation 'com.google.firebase:firebase-database:18.0.0'
}
  • Check https://stackoverflow.com/questions/57022157/manifest-merger-failed-attribute-applicationappcomponentfactory-cant-solve-th/57022608#57022608 – Gabriele Mariotti Jul 25 '19 at 10:03

1 Answers1

0

It means that one of your libraries is using AndroidX. So, you have to convert your app to AndroidX.

  • android.useAndroidX=true android.enableJetifier=true Put these lines in your gradle.properties.
  • npm install --save-dev jetifier
  • npx jetify
  • npx react-native run-android (your app should correctly compile and work)
  • Call npx jetify run in the postinstall target of your package.json (Any time your dependencies update you have to jetify again)