Reputation: 3547
I've just updated the play-services-ads dependency from
implementation 'com.google.android.gms:play-services-ads:19.6.0'
to
implementation 'com.google.android.gms:play-services-ads:20.1.0'
and now the ad doesn't work anymore. In fact, it doesn't compile. This is what I have:
import com.google.android.gms.ads.doubleclick.PublisherAdRequest;
import com.google.android.gms.ads.doubleclick.PublisherAdView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
PublisherAdView ad = findViewById(R.id.adView);
PublisherAdRequest adRq = new PublisherAdRequest.Builder().build();
ad.loadAd(adRq);
The doubleclick
package doesn't exist anymore; and thus neither do PublisherAdView
and PublisherAdRequest
. The documentation shows an AdView
instead of a PublisherAdView
. I remember vaguely that I had to deal with this before, and if I remember correctly it was an AdView
before I had to change it to PublisherAdView
.
Is the reason known why google keeps changing the API back and forth?
Upvotes: 1
Views: 1880
Reputation: 7979
The migration guide seems like in your case it's luckily just renames.
Using your example:
doubleclick.PublisherAdView
-> admanager.AdManagerAdView
doubleclick.PublisherAdRequest
-> admanager.AdManagerAdRequest
Ultimately, breaking changes with a new major version have to be expected. The release notes for 20.0.0 even explicitly state this will be a large change (along with all changes made):
This release is a MAJOR version update with several breaking changes. See the prepare for SDK v20 guide for more information on how to migrate.
Upvotes: 3