With the October update of the Google Play Services, AdMob was integrated into the library, which means Android developers no longer have to include the GoogleAdMobAdsSdk-x.x.x.jar
in a project's libs
folder. There's a nice migration guide that explains how to migrate from com.google.ads.*
to com.google.android.gms.ads.*
.
So far, so good. Migrating is a piece of cake, but... There's always a "but".
Previously, com.google.ads.AdRequest
used to have a setLocation(Location)
method that would allow you to augment the targeting information. That option is no longer available in com.google.android.gms.ads.AdRequest
, nor in its Builder
class.
I suppose my questions are: where and why did it go? The where is probably easily answered, because it simply seems to have been removed. I'd love for someone to prove me wrong here though, so feel free to comment if I'm overlooking something. That leaves the why.
Right now I can only speculate as to why it was removed:
- It was overlooked when AdMob was refactored to become part of the Google Play Services.
- Out of privacy concerns, Google has decided to no longer support this feature.
- Since AdMob is now part of the Google Play Services, perhaps it integrates with its Location API (i.e. the Fused Location Provider) and automatically supplies location information if available?
The first option seems unlikely, whereas the second one would be understandable. Not sure about the third, but considering the privacy implications, not too likely either. Any chance someone can give a conclusive answer on the matter, or perhaps point to a reliable source?
Note: Yes, I'm aware of the following remark in the docs:
Out of respect for user privacy, Google asks that you only specify location and demographic data if that information is already used by your app.
The app this issue came up for is already location-aware. In fact, it's a rather important aspect of the app. As the note says, since the user's location is already used by the app, supplying it with the ad request has been a valid use case so far.
Update:
With the 9 January blog post on the upcoming Google Play Services 4.1 update, there is a mention of location targetting being re-introduced through a new API:
Google Mobile Ads
With Google Play services 4.1, the Google Mobile Ads SDK now fully supports DoubleClick for Publishers, DoubleClick Ad Exchange, and Search Ads for Mobile Apps. You can also use a new publisher-provided location API to provide Google with the location when requesting ads. Location-based ads can improve your app monetization.
Currently I haven't found any updated documentation on this new API, but would expect it to become available very soon - as soon as rollout of Google Play Services 4.1 has been completed. Until then, I'll keep my initial answer below for reference.
Google has now updated the Android docs on the new features. See accepted answer below.