androidmanifest

Android Manifest merger failed (Kotlin / Android Studio)


I got a very common Error during coding my new App:

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:22.1.2] AndroidManifest.xml:32:13-58
is also present at [com.google.android.gms:play-services-ads-lite:22.5.0] AndroidManifest.xml:84:13-59 value=(@xml/gma_ad_services_config).
Suggestion: add 'tools:replace="android:resource"' to <property> element at AndroidManifest.xml to override.

I tried to use the Suggestion and added the tool argument to property element. This was not the right solution. I asked ChatGPT and Google for help, they gaved me similar solutions.

I endet up adding this to my AndroidManifest.xml

    <meta-data
    android:name="android.adservices.AD_SERVICES_CONFIG"
    tools:replace="android:resource"  <!-- Hier wird der Konflikt ersetzt -->
    android:resource="@xml/gma_ad_services_config" />

Same error, later I tried adding this:

    <meta-data
    android:name="android.adservices.AD_SERVICES_CONFIG"
    tools:replace="android:resource"
    android:resource="@xml/gma_ad_services_config" />


<meta-data
    android:name="android.adservices.AD_SERVICES_CONFIG"
    tools:replace="android:resource"
    android:resource="@xml/ga_ad_services_config" />

The

xmlns:tools="http://schemas.android.com/tools"

is set.

End of it: I'm giving up, all solutions that I found didn't solve my problem. Maybe there is just one line I didn't saw... Hopefully you guys can help me!

build.gradl.kts: https://pastebin.com/6z4d1KSB I need to add this:

dependencies {
 implementation 'com.google.android.gms:play-services-ads:22.5.0' 
}

AndroidManifest.xml: https://pastebin.com/XiUk7nqs I need to add this:

<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-XXXXXXXXXXXXXXXX~XXXXXXXXXX"/>

Solution

  • I see this is an existing issue as discussed here [https://github.com/googleads/googleads-mobile-flutter/issues/1095]

    As discussed there, can you try adding the following tag within your application tag in the Manifest.

    <property
                android:name="android.adservices.AD_SERVICES_CONFIG"
                android:resource="@xml/gma_ad_services_config"
                tools:replace="android:resource" />
    

    Hope this works!