1

Getting the Google Advertising ID on Android requires to import the play-services-ads dependency.

Starting from 17.0.0, this dependency enforces that the application manifest contain a <meta-data> tag with key com.google.android.gms.ads.APPLICATION_ID. Missing tag leads to an application crash.

But I want to retrieve the Google Advertising ID for ads purposes that are not related to Google mobile Ads, and I do not have an application ID.

Does anyone know how to proceed now ?

1 Answers1

3

You can use play-services-ads-identifier instead of play-services-ads.

implementation 'com.google.android.gms:play-services-ads-identifier:16.0.0'

This will import only the Advertising ID classes, without Google Mobile Ads/AdMob.

  • Cool, thanks. I was a bit sceptic about the 16.x version of ads-identifier (as this change was introduced in 17.0.0 of ads) but the 17.x play-services-ads is using exactly the same 16.0.0 version – bio007 Mar 07 '19 at 08:58