25

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.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Siva
  • 1,078
  • 4
  • 18
  • 36

5 Answers5

16

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.

Pang
  • 9,564
  • 146
  • 81
  • 122
buch0
  • 161
  • 1
  • 2
6

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)

Giorgos Neokleous
  • 1,709
  • 1
  • 14
  • 25
  • This is great to know! Unfortunately, the link to the documentation is no longer active. – AdamHurwitz Dec 05 '20 at 01:41
  • 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. – Giorgos Neokleous Dec 05 '20 at 10:13
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.

D.N.
  • 2,160
  • 18
  • 26
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

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
hasantr
  • 1
  • 1