Skip to content

Fixing Manifest Merger Failures for AD_SERVICES_CONFIG in AGP 8.3.0

Problem Overview

When updating to Android Gradle Plugin (AGP) version 8.3.0, you may encounter a build failure due to a manifest merger conflict related to AD_SERVICES_CONFIG. The error typically appears as:

Attribute property#android.adservices.AD_SERVICES_CONFIG@resource value=(@xml/ga_ad_services_config) 
from [com.google.android.gms:play-services-measurement-api:21.5.1]
is also present at [com.google.android.gms:play-services-ads-lite:22.6.0] value=(@xml/gma_ad_services_config).
Suggestion: add 'tools:replace="android:resource"' to <property> element

This occurs due to incompatible resource declarations between Google Play Services libraries (play-services-measurement-api and play-services-ads). AGP 8.3.0 enforces stricter manifest merging rules, exposing this conflict.

1. Preferred Solution: Update Dependencies (AGP 8.8.2+)

Fixed in Newer Versions

As of AGP 8.8.2 and play-services-ads:24.0.0, this issue has been resolved. Update your dependencies:

groovy
// Top-level build.gradle
plugins {
    id 'com.android.application' version '8.8.2' // OR HIGHER
    // ...
}

// App-level build.gradle
dependencies {
    implementation 'com.google.android.gms:play-services-ads:24.0.0' // OR HIGHER
}

2. Manifest Workaround (For Older Versions)

Add this declaration to your AndroidManifest.xml:

xml
<manifest 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"> <!-- Required namespace -->

    <application>
        <!-- Add inside <application> tag -->
        <property
            android:name="android.adservices.AD_SERVICES_CONFIG"
            android:resource="@xml/gma_ad_services_config"
            tools:replace="android:resource" />
    </application>
</manifest>

Key Notes:

  1. Declare xmlns:tools in the root <manifest> tag if not present
  2. Position the <property> tag inside the <application> block
  3. The tools:replace="android:resource" attribute resolves the conflict
groovy
// Downgrade play-services-ads (not ideal)
implementation 'com.google.android.gms:play-services-ads:22.2.0'
groovy
// Downgrade AGP (last resort)
plugins {
    id 'com.android.application' version '8.2.2'
}

Why This Works

The conflict arises because two Google libraries declare the same AD_SERVICES_CONFIG attribute with different resources (ga_ad_services_config vs. gma_ad_services_config). The tools:replace directive explicitly tells the manifest merger which resource value to prioritize during the merge process.

Compatibility Considerations

  • Projects using AdMob should initialize the SDK properly:
java
// In your Application class
@Override
public void onCreate() {
    super.onCreate();
    MobileAds.initialize(this);
}
  • Resource conflicts may arise again when adding new Google Play libraries

Best Practices

  1. Always test AGP upgrades in a development branch first
  2. Check library compatibility for major dependency updates
  3. Use the latest stable versions of Google Play libraries
  4. Clean project after manifest changes (Build > Clean Project)

Future Prevention

Keep AGP and Google dependencies regularly updated to prevent manifest conflicts. Google has acknowledged and fixed this specific issue in newer releases.