You have a great React Native app. You love it. People will love it (right?). Now let's monetize it. So you install react-native-google-mobile-ads. You rebuild just to be safe. And your app never builds again. #ffs!!!!!!!
The Error
Error: Attribute property#android.adservices.AD_SERVICES_CONFIG@resource value=(@xml/ga_ad_services_config) from [com.google.android.gms:play-services-measurement-api:22.0.2] AndroidManifest.xml:32:13-58 is also present at [com.google.android.gms:play-services-ads-lite:23.2.0] AndroidManifest.xml:92:13-59 value=(@xml/gma_ad_services_config). Suggestion: add 'tools:replace="android:resource"' to <property> element at AndroidManifest.xml to override. FAILURE: Build failed with an exception.
The Fix
Just update your AndroidManifest.xml (of course nobody will tell you where that is or where in the file to update it).
File Path: ./android/app/src/main/AndroidManifest.xml
Warning
The xml below is an edit from the default AndroidManifest.xml. If you already made edits to your manifest, you can just copy and past the property tag (and maybe the namespace - see below).
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
>
<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"
android:supportsRtl="true">
<property
android:name="android.adservices.AD_SERVICES_CONFIG"
android:resource="@xml/gma_ad_services_config"
tools:replace="android:resource" />
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize|uiMode"
android:launchMode="singleTask"
android:windowSoftInputMode="adjustResize"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Last Gotcha
Everything should now work but please realize that there are two fixes in the xml above. First is the property with tools:replace. The second is the tools xml namespace added at the top. If you only add the property without having the tools namespace, you will get another error (but nobody tells you this).
Execution failed for task ':app:processDebugMainManifest'. > com.android.manifmerger.ManifestMerger2$MergeFailureException: Error parsing
Ok. Now everything should work (or not because it's React Native, Android, gradle, etc).