Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google-ads DFP multiple ad-sizes gives failure

I am trying to implement multiple ad sizes with google ads DFP as is described in the documentation

But the weird thing is, that if I use a single ad size as shown in the code below, it works:

 _adView = new PublisherAdView(activity);
    _adView.setAdSizes(AdSize.BANNER);

But if I use multiple ads, in an equal way as described in the documentation, shown below, the request fails:

 _adView = new PublisherAdView(activity);
    _adView.setAdSizes(AdSize.BANNER, new AdSize(120, 20), new AdSize(250, 250));

So the first snippet works and gives ads, while the second gives the following in the logcat:

12-07 12:17:17.082  30786-30786/app.myappname.nl I/Ads﹕ Ad opening.
12-07 12:17:17.109  30786-30812/app.myappname.nl W/Ads﹕ The ad response must specify one of the supported ad sizes.
12-07 12:17:17.167  30786-30786/app.myappname.nl I/Ads﹕ Scheduling ad refresh 60000 milliseconds from now.
12-07 12:17:17.167  30786-30786/app.myappname.nl W/Ads﹕ Failed to load ad: 0

I have also tried using only standard ad sizes, but this does not make any difference. Does anyone knows why this happens and how to solve it?

like image 854
Jasper Avatar asked Dec 07 '15 11:12

Jasper


1 Answers

For me this happened because I had added my device as a test device to get Google test advertisements.

final PublisherAdRequest.Builder adRequestBuilder = new PublisherAdRequest.Builder()
            .addTestDevice("BBE743F18R0143D88563501D114CF633")

After removing the testDevice line and using real ads I could send the array of sizes to request an ad.

like image 121
Simon Raes Avatar answered Nov 22 '22 22:11

Simon Raes