Google Play Console AD_ID permission error

Google Play Console AD_ID permission error

In Google Play Console, if you get the following error. This post will show how to solve it.

Error
This release includes the com.google.android.gms.permission.AD_ID permission but your declaration on Play Console says your app doesn't use advertising ID.

You must update your advertising ID declaration.

Update declaration

Solution

If you are not using this permission, want to overwrite the dependence's setting and force removing this permission.

In AndroidManifest.xml, directly under <manifest> tag, add the following line as early as possible:

<manifest ...>
  <uses-permission android:name="com.google.android.gms.permission.AD_ID" tools:node="remove"/>

Also, include the tools in manifest tag with:

<manifest
	xmlns:tools="http://schemas.android.com/tools"
>
    

By setting this, the AdversitingIdClient.Info.getId() method will return 00000000-0000-0000-0000-000000000000 and does not affect other behavior of the app.

Rationale

What is com.google.android.gms.permission.AD_ID permission?

From late 2021, on Android 12 devices, Android imposes a requirement when an app wants to use user advertising id.

Docs: https://developers.google.com/android/reference/com/google/android/gms/ads/identifier/AdvertisingIdClient.Info#public-string-getid

Starting from late 2021, on Android 12 devices, when isLimitAdTrackingEnabled() is true, the returned value of this API will be 00000000-0000-0000-0000-000000000000 regardless of the app’s target SDK level.
In early 2022, this change will be applied to all the devices that support Google Play services.
Apps with target API level set to 33 (Android 13) or later must declare the normal permission com.google.android.gms.permission.AD_ID as below in the AndroidManifest.xml in order to use this API.
This permission will be granted when the app is installed.
If this permission is not declared, the returned value will be 00000000-0000-0000-0000-000000000000 starting early 2022.
Until then, to help developers, a warning line is logged if the permission is missing when the app targets API level 33 (Android 13) or higher.
This warning line is under the Log tag AdvertisingIdSettings.

Why is this permission included in your manifest even though you are not declaring it?

Manifest file is merged into the final application manifest by merging the manifest files from all dependencies.

Check the official docs on how the merging works: https://developer.android.com/build/manage-manifests#merge-manifests

Where is the finally merged app manifest?

Note: I am considering the release build. If you want to check debug build, replace release in the file path with debug.

The final app manifest file can be checked at build/app/intermediates/merged_manifest/release/AndroidManifest.xml.

Or in the outputted aab file at build/app/outputs/bundle/release/app-release.aab, find it at base/manifest/AndroidManifest.xml.

Which dependency declares the AD_ID permission?

Note: I am considering the release build. If you want to check debug build, replace release in the file path with debug.

The manifest merging log is stored at build/app/outputs/logs/manifest-merger-release-report.txt.

uses-permission#com.google.android.gms.permission.AD_ID
ADDED from [com.facebook.android:facebook-core:16.0.1] /home/transang/.gradle/caches/transforms-3/9ba6d5e2710ab5efac0fdb201e4c1658/transformed/jetified-facebook-core-16.0.1/AndroidManifest.xml:16:5-79
	android:name
		ADDED from [com.facebook.android:facebook-core:16.0.1] /home/transang/.gradle/caches/transforms-3/9ba6d5e2710ab5efac0fdb201e4c1658/transformed/jetified-facebook-core-16.0.1/AndroidManifest.xml:16:22-76
provider#com.facebook.internal.FacebookInitProvider
ADDED from [com.facebook.android:facebook-core:16.0.1] /home/transang/.gradle/caches/transforms-3/9ba6d5e2710ab5efac0fdb201e4c1658/transformed/jetified-facebook-core-16.0.1/AndroidManifest.xml:29:9-32:40
	android:authorities
		ADDED from [com.facebook.android:facebook-core:16.0.1] /home/transang/.gradle/caches/transforms-3/9ba6d5e2710ab5efac0fdb201e4c1658/transformed/jetified-facebook-core-16.0.1/AndroidManifest.xml:31:13-72
	android:exported
		ADDED from [com.facebook.android:facebook-core:16.0.1] /home/transang/.gradle/caches/transforms-3/9ba6d5e2710ab5efac0fdb201e4c1658/transformed/jetified-facebook-core-16.0.1/AndroidManifest.xml:32:13-37
	android:name
		ADDED from [com.facebook.android:facebook-core:16.0.1] /home/transang/.gradle/caches/transforms-3/9ba6d5e2710ab5efac0fdb201e4c1658/transformed/jetified-facebook-core-16.0.1/AndroidManifest.xml:30:13-70
Buy Me A Coffee