Android Material and appcompat Manifest merger failed in react-native or ExpoKit

10,790

Solution 1

I found a solution through my search by referring to @MehulSolanki answer.

I add

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

in my on AndroidManifest.xml

and update com.android.tools.build:gradl:

dependencies {
    classpath 'com.android.tools.build:gradle:3.2.1'
  }

And add this in your gradle.properties file

android.useAndroidX=true
android.enableJetifier=true

ERROR: [TAG] Failed to resolve variable '${animal.sniffer.version}'

ERROR: [TAG] Failed to resolve variable '${junit.version}'

In case of above error

  1. File -> Invalidate Caches / restart
  2. Build -> Clean project

error: package android.support.annotation does not exist error: cannot find symbol class Nullable

In case of above error

Add implementation 'androidx.annotation:annotation:1.1.0'

change import android.support.annotation.Nullable; => androidx.annotation.Nullable;

change import android.support.annotation.NonNull; => androidx.annotation.NonNull;

Compile version and target version should be 28.

Solution 2

Upgrading 'react-native-device-info' to version 2.1.2 fixed the error for me. See github.com/facebook/react-native/issues/25294#issuecomment-503024749

In short: the library used "services-gcm:+" as a dependency, and the latest gcm version caused this problem.

Solution 3

The root cause is related migration to Androidx, google play service updated to androidX Thanks to MR03web This problem belongs to react-native-device-info? best option is to upgrade react-native-device-info using

yarn upgrade [email protected]
cd android && gradlew clean
react-native run-android

or if you don't want to upgrade you should exclude com.google.android.gms from react-native-device-info like this. Thanks

implementation(project(":react-native-device-info"),  {
  exclude group: "com.google.android.gms"
})
implementation "com.google.android.gms:play-services-gcm:16.0.0"

Solution 4

Add the following to your gradle.properties then clean/rebuild

googlePlayServicesVersion=16.1.0
firebaseVersion=17.6.0

Solution 5

Add 'tools:replace="android:appComponentFactory"' in your AndroidManifest.xml inside <application> tag

Your AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="ru.chopcode.myapplication">

    <application
        tools:replace="android:appComponentFactory"
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
   </application>

Share:
10,790
hong developer
Author by

hong developer

Updated on July 16, 2022

Comments

  • hong developer
    hong developer almost 2 years

    I updated 'android.support:appcompat-v7' to 28.0.0.

    But it brought an error from the build.

    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:8:5-23:19 to override.
    

    Then I get this error in my Logcat:

    Manifest merger failed

    my app.gradle:

      configurations.all {
        resolutionStrategy.force 'com.android.support:design:28.0.0'
        resolutionStrategy.force "com.android.support:support-v4:28.0.0"
        resolutionStrategy.force "com.android.support:support-media-compat:28.0.0"
      }
    ...
    dependencies {
      implementation 'com.android.support:multidex:1.0.1'
    
      // Our dependencies
      implementation 'com.android.support:appcompat-v7:28.0.0'
    
    
      implementation 'com.android.support:appcompat-v7:28.0.0'
    }
    

    how do I fix it?

    I need your solutions.

    Thank you in advance.