How to reset Google Advertising ID in Android Programmatically?
Asked Answered
P

5

26

I'm trying to reset google Advertising ID programmatically for automation purposes.

I'm able to fetch the Advertising ID and isLimitAdTrackingEnabled. But I want to reset the ID programmatically

https://developers.google.com/android/reference/com/google/android/gms/ads/identifier/AdvertisingIdClient.Info

Manually a user can reset the google advertising id from google settings application.

Popham answered 3/11, 2016 at 19:10 Comment(1)
is there any solution?Hyades
Z
17

You can reset the Advertising ID programmatically.

Try to execute this command with root permission:

rm -f /data/data/com.google.android.gms/shared_prefs/adid_settings.xml

If you removed the XML file, it will generate a new Advertising ID and XML file automatically.

I confirmed it with Android 4.4 API device.

Zoilazoilla answered 20/8, 2018 at 2:46 Comment(3)
confirmed on android 5Carhart
Confirmed on Android 7. Thanks!Wartime
Confirmed on Android 11Trihedral
T
7

According to the Android docs, the advertising ID can only be reset by the user.

The advertising ID APIs do not include a "reset" method. Only users can initiate a reset of their own advertising IDs, through the Google Settings application.

Source

Update Dec 2020:

The link above is broken. Seems like the doc was removed at this commit.

In the d.android.com section, the Google Advertising ID is mentioned as user-resettable several times which indicates that it's up to the user's to reset the identifier and not up to the developers. (link)

Taro answered 22/2, 2018 at 21:37 Comment(2)
This is great to know! Unfortunately, the link to the documentation is no longer active.Lenardlenci
Thanks for pointing that out @AdamHurwitz. I have updated it with some more relevant information. Seems like a similar doc does not exist but the docs are clear that Google Advertising Id is user-resettable which indicates a similar thing.Taro
F
5

Note: While this does NOT answer the question as posed, it may at least meet the criteria of the intent, and may be helpful to others searching for a workaround.

If you are able to create an Activities shortcut (such as widget functionality provided by Nova Launcher or other third party launchers), you can create an Activity link to Google Play services > Ads (specifically, .ads.settings.AdsSettingsActivity). The resultant shortcut has no icon, but has the name "Ads."

A user can click on this shortcut from their launcher of choice and be taken directly to the sub-menu that allows a user to click on "Reset advertising ID." You can even create an Activities widget from the stock launcher, as long as Nova Launcher or other third party launcher is installed.

The net result is there is a significant reduction in the number of clicks required to perform the action:

  • Before: (5 clicks) Menu > Settings > Google > Ads > Reset advertising ID
  • After: (2 clicks) Ads Activities shortcut > Reset advertising ID

Reference: For more information on how to create an Activity widget, check out this link.

Fizzy answered 4/1, 2019 at 17:57 Comment(0)
G
0

You can reset it using a series of adb shell commands too (tested it on android-28, google_apis, x86 SDK)

adb root
adb shell am start -n com.google.android.gms/.ads.settings.AdsSettingsActivity
adb shell su root input tap 100 100
adb shell su root input tap 280 360

This will basically open your Google Ads activity, and then automate the tapping behavior on the screen which will reset the device ID.

The tapping behavior followed is in this video: How to set GAID

Gadolinium answered 12/11, 2020 at 6:27 Comment(0)
T
0

@uddeshya-singh to complete the method it gave with keystrokes.

shell am start -n com.google.android.gms/.ads.settings.AdsSettingsActivity

shell input keyevent 20
shell input keyevent 66
shell input keyevent 66
Tarp answered 28/5, 2022 at 7:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.