JoeyScott
JoeyScott

Reputation: 25

React native "Execution failed for task: ':app:processDebugManifest' after adding Admob module

Working with a React Native project and ready for release but running into this error:

Execution failed for task ':app:processDebugManifest'.
> 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:7:5-117 to override.

Works fine before adding the "react-native-admob" module through npm using "npm i --save react-native-admob@next"

In order to complete the project I need admob running! help please!

Upvotes: 1

Views: 1032

Answers (1)

Rebecca Tay
Rebecca Tay

Reputation: 331

You are having this issue because your dependencies are depending on android support libaries. some have the older version named eg. 'com.android.support..', while some depend on the newer androidX library with names 'androidx.core....'. Having both com.android.support and androidx libaries in the same project will prevent the app from building.

This issue likely arose from the June 17 update to google play services which included major breaking changes to android support libraries. https://developers.google.com/android/guides/releases.

To fix this issue, identify all yr react-native packages and check if they have dependencies (listed under the play services release notes) that have been forceably updated to the newest version which gives androidx. If you have the android folder in the project that holds your build.gradles, try cd android, and then run ./gradlew app:dependencies --scan. This generates a unique link to a report for you to inspect each packages' dependencies. Expand your dependencies and make sure react-native packages when fully expanded do not contain any androidx file. Check all paths, testCompileClasspath, testRuntimeClassPath....

If you do have affected dependencies, you will need to force those packages to use the older version with com.android.support. This issue link has several suggestions on how to implement. https://github.com/facebook/react-native/issues/25292

I fixed this issue happening with our builds couple days back by doing stuff similar to this in my app/build.gradle:

implementation(project(':react-native-camera')){
  exclude group: 'com.google.android.gms'
}

You might also need to declare some top-level configuration to force google play service and firebase to use specific version.

The official documention on androidx recommends people to switch to using the newer library androidx, and tell you to enable androidX and Jettifier to true. This DOES NOT work 100% for react-native libraries. So don't upgrade packages to androidx until you are sure all dependencies you have in your project are eligible for the migration to androidx.

Upvotes: 1

Related Questions