Search code examples
androidadmobgoogle-dfpadview

Google Ad not visible when using custom ad size with PublisherAdView


When using PublisherAdView with size: AdSize.BANNER. The ad I wanna display works pretty fine, but when setting a custom size, the operation does not succeed. In fact the ad is being loaded but not displayed, I go successfully in the callbackonAdLoaded:

mAdView.setAdListener(new AdListener() {
        @Override
        public void onAdLoaded() {
            super.onAdLoaded();
            Log.d(TAG, "Ad loaded");
        }
});

I simply set my custom size like this:

AdSize[] adSizes = {new AdSize(88, 31), AdSize.BANNER};
mAdView = new PublisherAdView(getActivity());
mAdContainer.addView(mAdView);
mAdView.setAdUnitId(getActivity().getResources().getString(R.string.ad_unit_id));
mAdView.setAdSizes(adSizes);

No rocket-science here but I'm doubting it is possible to use a custom size. Has anyone experienced this?


Solution

  • Actually you can use any size you want (as long as it fits), my client provides small ad sizes and we manage to make it work. "As long as it fits" means for example, when you write something like:

    AdSize[] adSizes = {new AdSize(89, 31), AdSize.SMART_BANNER};
    

    And your provided ad size is 88X31, that won't work.