Reputation: 311
I am trying add AdMob ads in my app. when I add AdMob dependency and implement ads after when I run the app I got this error.
Manifest merger failed : Attribute property#android.adservices.AD_SERVICES_CONFIG@resource value=(@xml/ga_ad_services_config) from [com.google.android.gms:play-services-measurement-api:21.6.2] AndroidManifest.xml:32:13-58
is also present at [com.google.android.gms:play-services-ads-lite:23.0.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.
When I see Merged Manifest here is also error
Merge Errors Error: Attribute property#android.adservices.AD_SERVICES_CONFIG@resource value=(@xml/ga_ad_services_config) from AndroidManifest.xml:32:13-58 is also present at 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. cryptotradingsignals.app main manifest (this file), line 31
I also Add this in manifest still got error but different error
tools:replace="android:resource"
Any Idea how to solve?
I am looking for a result to solve my error in android latest version Laguana
Upvotes: 16
Views: 4068
Reputation: 31
The Manifest merger failed issue with android.adservices.AD_SERVICES_CONFIG@resource
typically occurs when there are conflicts or missing configurations related to Google's Ad Services or Ad SDK in your Android project.
You can take following steps to solve the issue
1. Verify Dependencies Ensure you're using compatible versions of Google Ads. Add or update these dependencies in your build.gradle file, in my case it is the following
implementation "com.google.android.gms:play-services-ads:23.6.0" // Ensure latest stable version
2. Add or Correct the XML Configuration
Create or verify the res/xml/gma_ad_services_config.xml file. It should look like this:
<?xml version="1.0" encoding="utf-8"?>
<ad-services-config xmlns:android="http://schemas.android.com/apk/res/android">
<network-security-config>gma_ad_services_security_config</network-security-config>
</ad-services-config>
3. Check Manifest File
Ensure your AndroidManifest.xml has the correct metadata declaration
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application>
<meta-data
android:name="android.adservices.AD_SERVICES_CONFIG"
android:resource="@xml/gma_ad_services_config" />
</application>
</manifest>
4. Enable Ad Services in gradle.properties
Add the following flag if required by your SDK version
android.enableAdServices=true
5. Clean and Rebuild
After making these changes, clean and rebuild your project, this works for me.
Upvotes: 0
Reputation: 837
I added the following code in AndroidManifest.xml
. Not sure if this is the final solution, but it works for me now.
<property
android:name="android.adservices.AD_SERVICES_CONFIG"
android:resource="@xml/gma_ad_services_config"
tools:replace="android:resource" />
...
</application>
Upvotes: 17