Viewpager2 fragment layout disappears when adaptive banner is used

288 views
Skip to first unread message

vin...@gmail.com

unread,
May 12, 2021, 3:39:17 AM5/12/21
to Google Mobile Ads SDK Developers
Hi,

There is a strange phenomenon if I use adaptive ad banner instead of SMART_BANNER adsize.
The adaptive banner implementation follows this: https://developers.google.com/admob/android/banner/adaptive

The MobileAds.initialize is called in the Splash activity. Firebase BoM 27.1.0 is used and adview is imported as  com.google.android.gms.ads.AdView. But it happened also with earlier version of Firebase BoM. The main activity is a FragmentActivity which uses viewpager2 widget.

After install, when the app is launched and the adbanner gets visible the whole viewpager2 disappears. In case I run the app again sometimes everything is ok.

I've uploaded a version to closed beta channel, which starts with adaptive banner, so if you give me an email address, I can add you as a tester and you can get any logcat logs.

Now there is also a strange thing: I am not able to reproduce it if I install the app from Android Studio (4.2) and use debug version (test ads are shown in this case), but as soon as I use the closed beta version from play, it happens.

My device is Xiaomi M9T Pro (Android 10), but it happens on other devices as well, see recent one star reviews of the apps.

Please check this case as SMART_BANNER is depreciated, so sooner or later I will have to use the new adaptive format.

Video: https://drive.google.com/file/d/1Kfa5un9vyfD2AxWDuGPKxGbrq4PcnHea/view?usp=sharing

Thanks,
Gabor

Mobile Ads SDK Forum Advisor Prod

unread,
May 12, 2021, 5:51:30 AM5/12/21
to vin...@gmail.com, google-adm...@googlegroups.com

Hi Gabor,

Thank you for reaching out to us.

I tried to open the attached video you provided, but I got access denied. Kindly provide permission to mobileads...@gmail.com, so that we can check your concern. Also, could you please provide us a sample app with minimum modification and steps to replicate which the issue is shown. You can send it via Reply privately to author option or send it directly to mobileads...@gmail.com.

Regards,

Google Logo
Princess Pamela Pineda
Mobile Ads SDK Team
 


ref:_00D1U1174p._5004Q2HAFuR:ref

vin...@gmail.com

unread,
May 12, 2021, 7:08:42 AM5/12/21
to Google Mobile Ads SDK Developers
Hi,

Permission to video is granted and the provided email address is now added to Closed Beta testers, so just go to https://play.google.com/store/apps/details?id=org.vinczu.ultimatefishingknots , join Beta testing and install the app and open it.
That's all.

Not sure what do you mean by  "sample app with minimum modification",  as the app what produce this behaviour is available in Beta testing.

Thanks,
Gabor

Mobile Ads SDK Forum Advisor Prod

unread,
May 12, 2021, 2:32:40 PM5/12/21
to vin...@gmail.com, google-adm...@googlegroups.com
Hi Gabor,

Thank you for giving us access to the video. A few more questions to ask. As it looks like this is still a beta version of your app this is one thing that can cause delay or restrictions in serving ads to you. The other thing is while we are able to see the video and what is happening. We usually request a sample app so that we can look at the actual code and implementation being used. From this we are able to give more helpful advise. You can also use one of our sample apps as a basis for your sample.

Regards,
Google Logo
William Pescherine
Mobile Ads SDK Team
 


ref:_00D1U1174p._5004Q2HAFuR:ref

Crone

unread,
May 12, 2021, 5:20:26 PM5/12/21
to Google Mobile Ads SDK Developers
Hello! I have same issues. But i found this bug only with Tik-Tok ads.
Watch my video from 0.30 when Adaptive Banner is loaded my RecycleView is setting position to 0 but in my bussines logic it inpossible

app: com.crone.skins999
I using com.google.android.gms:play-services-ads:20.1.0

And other apps have same issues


среда, 12 мая 2021 г. в 21:32:40 UTC+3, mobileadssdkforumadvisor:

vin...@gmail.com

unread,
May 13, 2021, 1:41:29 AM5/13/21
to Google Mobile Ads SDK Developers
Hi,

The whole source is shared via Drive and link is sent to mail address you provided.

Thanks,
Gabor

Mobile Ads SDK Forum Advisor Prod

unread,
May 13, 2021, 11:24:18 AM5/13/21
to vin...@gmail.com, google-adm...@googlegroups.com
Hi Gabor,

Thank you for sending us over the app to review. We were able to run tests on our end and see that ads appear to be showing as intended. In reading over your description, you even mention that it works fine when loading from Android Studio. The issue seems to be when using your Beta app? For this it would seem to be working as expected, if you have real ads being shown on the Beta. We would strongly suggest that if you want to show ads during beta to probably use the test Ids as it is not recommended to use live ads.

Also with smart banners being deprecated we would suggest moving all your ads to adaptive banners to make sure not to have any conflicts, especially if using v20.

vin...@gmail.com

unread,
May 13, 2021, 12:44:52 PM5/13/21
to Google Mobile Ads SDK Developers
Hi,

Let me summarize, so if I use adaptive banner ad:
-I install a debug version to my phone from Android Studio: test ad is shown, viewpager2 content is visible
-I upload a release version to Beta channel: real ads shown, viewpage2 content disappears
-if I promote the very same beta version to Production the same happens: real ads shown, viewpage2 content disappears(see recent one star reviews of the app)

So this means, that I can not use adaptive banner until this strange error is not investigated and fixed.

Br,
Gabor

Crone

unread,
May 13, 2021, 2:12:51 PM5/13/21
to Google Mobile Ads SDK Developers
Hi,
I found the reason why it's happening
Because Adaptive Banner has video inside...
I hope you fix it soon!
d9NvfJdz-7s.jpgzHnIGcjTySw.jpg



четверг, 13 мая 2021 г. в 19:44:52 UTC+3, vin...@gmail.com:

Mobile Ads SDK Forum Advisor Prod

unread,
May 13, 2021, 4:46:05 PM5/13/21
to vin...@gmail.com, google-adm...@googlegroups.com
Hi Gabor,

Thank you for the insight and I have been looking more into this for you. I was finally able to get it to trigger as seen in your video. I have also been looking more into the code of how you have it setup. So a few things that I saw and just want to get a better understanding of.

When I install on our virtual device I always get a billing error issue, at app launch. Not sure if that is something that you have built into the app or if it is an AdMob thing. Also I saw that when everything was ok, it looked like when clicking on a loop, it brought you to the walk through of doing the loop. Which has a RecyclerView with ads in it every so often. What I have seen then is at some point I lost that, and started to see banner views in it instead. Then, eventually I did not see anything but the banner views.

When looking at it, just seems like there is something in the fragment setup that breaks, and once it starts to break just keeps breaking itself even more, thus causing what you are seeing.

Not seeing any logcat errors though is also making it hard to pinpoint.

vin...@gmail.com

unread,
May 14, 2021, 1:25:33 AM5/14/21
to Google Mobile Ads SDK Developers
Hi Crone,

Very good point! So I went to admob console and at banner's 'Ad type' I switched off the video and made several uninstall/install tests and bingo: fault disappeared. As soon as I turned 'video' on again, this disappearing fault was there again.

Thanks for this cool notice, this will bring us closer to the solution for sure,
Gabor

vin...@gmail.com

unread,
May 14, 2021, 4:49:47 AM5/14/21
to Google Mobile Ads SDK Developers
hi,

Yes, I also seen very few times the unsuccessful setup of billing connection on real deives. I did't really use virtual devices, but will check. I'll have to implement the retrying of billing connection if it fails for the first time.
But anyway, it think it does not have to do anything with this adaptive banner phenomenon.

Have you seen mail from Crone and reply from me? So looks the problem is the video format of the adaptive banner.
Can you make the test adaptive banner so, that it would be video format? Would be easier to test and would be useful for others also to see different types (maybe alternately: 1 image/1 video).

Thanks,
Gabor

Mobile Ads SDK Forum Advisor Prod

unread,
May 14, 2021, 12:52:54 PM5/14/21
to vin...@gmail.com, google-adm...@googlegroups.com
Hi Gabor,

Thank you for the response back, I have been looking into this more on our end. First, I have not seen any messages from Crone, I have just seen one or two that you sent yesterday and nothing more then what we have spoken about so far.

Also as for feeding particular ads into the adaptive banner, this is a bit harder to do. As it is based on various backend systems of which we have no control over. Within regards to that what we would also suggest then is to use Charles and get the logs of ads that are being served to you. If you find a video ad, then send that to us and we can work with it ion our end.

vin...@gmail.com

unread,
May 16, 2021, 11:50:11 AM5/16/21
to Google Mobile Ads SDK Developers
Hi,

For the test adaptive ads: it is now always image format, so I meant that you should also have a video format test adaptive ad.
Yuo can choose any video ads, so I don't see the point about selecting one and get logs with Charles.

Br,
Gabor

Mobile Ads SDK Forum Advisor Prod

unread,
May 17, 2021, 3:07:31 AM5/17/21
to vin...@gmail.com, google-adm...@googlegroups.com

Hi Gabor,

Thank you for your response.

As my colleague mentioned, we needed a copy of Charles log that capturing the ads that been served to you. It will be a big help in our end to investigate this further.

Regards,

Google Logo
Princess Pamela Pineda
Mobile Ads SDK Team
 


ref:_00D1U1174p._5004Q2HAFuR:ref

vin...@gmail.com

unread,
May 18, 2021, 8:51:56 AM5/18/21
to Google Mobile Ads SDK Developers
Hi,

Problem is found: for video adaptive banner ad, the adView.getHeight() gives back a faulty high value. This means that viewpager2 content does not disappear, but it gets a huge padding.
This is the modified addOnGlobalLayoutListener in Main.java:

adView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
                    @Override
                    public void onGlobalLayout() {
                        if ((adView.getTag() != null) && (adView.getTag() instanceof Boolean)) {
                            int lAdHeight = adView.getHeight();
                            int lAdWidth = adView.getWidth();
                            Log.d(TAG, "Ads: Google banner: Width x Height=" + lAdWidth + " x " + lAdHeight);

                            int manual_padding = Utils.readPreferences_int(myActivity, "padding", 0);
                            Toast.makeText(myContext, "lAdHeight = " + lAdHeight + "\n" +
                                    "manual padding = " + manual_padding, Toast.LENGTH_SHORT).show();

                            Log.d(TAG, "Ads: 1. viewpager: Width x Height=" + viewPager.getWidth() + " x " + viewPager.getHeight());
                            Log.d(TAG, "Ads: 1. viewpager: getPaddingBottom=" + viewPager.getPaddingBottom());
                            if ((0 != lAdHeight) && (0 == viewPager.getPaddingBottom())) {
                                viewPager.setPadding(0, 0, 0, manual_padding > 0 ? manual_padding : lAdHeight);
                                Log.d(TAG, "Ads: 2. viewpager: Width x Height=" + viewPager.getWidth() + " x " + viewPager.getHeight());
                                Log.d(TAG, "Ads: 2. viewpager: getPaddingBottom=" + viewPager.getPaddingBottom());
                            }
                        }
                    }
                });

               
These are the logs:
2021-05-18 14:32:51.096 9715-9715/? D/Main: Ads: adview onAdLoaded
2021-05-18 14:32:51.102 9715-9715/? D/Main: Ads: Google banner: Width x Height=1080 x 1982
2021-05-18 14:32:51.113 9715-9715/? D/Main: Ads: 1. viewpager: Width x Height=1080 x 1872
2021-05-18 14:32:51.114 9715-9715/? D/Main: Ads: 1. viewpager: getPaddingBottom=0
2021-05-18 14:32:51.114 9715-9715/? D/Main: Ads: 2. viewpager: Width x Height=1080 x 1872
2021-05-18 14:32:51.114 9715-9715/? D/Main: Ads: 2. viewpager: getPaddingBottom=1982
2021-05-18 14:32:51.140 9715-9715/? D/Main: Ads: Google banner: Width x Height=1080 x 1982
2021-05-18 14:32:51.143 9715-9715/? D/Main: Ads: 1. viewpager: Width x Height=1080 x 1872
2021-05-18 14:32:51.143 9715-9715/? D/Main: Ads: 1. viewpager: getPaddingBottom=1982
2021-05-18 14:32:51.202 9715-9715/? D/Main: Ads: Google banner: Width x Height=1080 x 170
2021-05-18 14:32:51.206 9715-9715/? D/Main: Ads: 1. viewpager: Width x Height=1080 x 1872
2021-05-18 14:32:51.206 9715-9715/? D/Main: Ads: 1. viewpager: getPaddingBottom=1982
2021-05-18 14:32:51.539 9715-9715/? D/Main: Ads: Google banner: Width x Height=1080 x 170
2021-05-18 14:32:51.542 9715-9715/? D/Main: Ads: 1. viewpager: Width x Height=1080 x 1872
2021-05-18 14:32:51.542 9715-9715/? D/Main: Ads: 1. viewpager: getPaddingBottom=1982


Strange is that when addOnGlobalLayoutListener is triggered for the 3rd time, the height of the adview gets the real value (170) from that point:
2021-05-18 14:32:51.202 9715-9715/? D/Main: Ads: Google banner: Width x Height=1080 x 170

This is how to test:
-sign up to the beta version and install it
-the toast will show the height of the advew and the "manual padding" value
-you'll see from the toasts that height of the adview is changed for the 3rd toast

About "manual padding":
-to set the "manual padding", go to Menu->About and at the top enter a value, e.g. 300 and press enter
-restart the app
-now if "manual padding" is bigger than 0, that will be used and viewpager will get that padding, so content of the viewpager will be visible according to manual padding value.

Please start to investigate why adaptive video banner has such abnormal value via getHeight.

Thanks,
Gabor

Mobile Ads SDK Forum Advisor Prod

unread,
May 18, 2021, 12:52:49 PM5/18/21
to vin...@gmail.com, google-adm...@googlegroups.com
Hi Gabor,

Thank you for bringing this information to our attention. Before I bring this to my team to look into, I just want to check to make sure that the only reason for using or getting the height is for testing purposes. You are not attempting to change the height or anything like that in the app yourself. Just as a note also when looking at our documents the adaptive banner should never be over 15%, so just want to see if there is any manipulation being done on your end also.

Regards,
Google Logo
William Pescherine
Mobile Ads SDK Team
 


ref:_00D1U1174p._5004Q2HAFuR:ref

vin...@gmail.com

unread,
May 18, 2021, 1:14:08 PM5/18/21
to Google Mobile Ads SDK Developers
Hi,

The reason why I need the height of the banner to be able to set the same size of padding to the viewpager (as I'm not adding the banner from xml), so this is not for testing purpose. The production version now use the SMART size banner with this same technique and that is working without this strange phenomenon.

I can confirm that there is no any manipulation, that strange value is returned by adView.getHeight.
I have uploaded the full source, which was used to build the version in the beta channel and shared with mobileads...@gmail.com

Thanks,
Gabor

Mobile Ads SDK Forum Advisor Prod

unread,
May 18, 2021, 5:52:22 PM5/18/21
to vin...@gmail.com, google-adm...@googlegroups.com
Hi Gabor,

Thank you for the additional information. I will be bringing this to our team to look into more and see what feedback they send us.

vin...@gmail.com

unread,
May 19, 2021, 1:10:54 PM5/19/21
to Google Mobile Ads SDK Developers
Hi,

Just an update, so I've found this Testing Creative Types page, so I tested all banner compatible ad types and found this stange fault only for "video_app_install" type, so it now can be tested also with test ad. This is what I asked before if it is possible to show different test ad types.

Br,
Gabor

Mobile Ads SDK Forum Advisor Prod

unread,
May 19, 2021, 3:42:01 PM5/19/21
to vin...@gmail.com, google-adm...@googlegroups.com
Hi Gabor,

Thank you for the additional information. I have made sure to pass that along to our team. As you have stated and shown clearly there is an issue where the area of the ad is vastly larger than the ad and what would appear to be the screen too.

vin...@gmail.com

unread,
Jul 8, 2021, 2:04:01 AM7/8/21
to Google Mobile Ads SDK Developers
Hi William,

Do you have any update on this issue?

Thanks,
Gabor

Mobile Ads SDK Forum Advisor

unread,
Jul 8, 2021, 6:18:26 AM7/8/21
to vin...@gmail.com, google-adm...@googlegroups.com
Hi Gabor,

Thank you for your patience here.

The team tried to reproduce the issue, unfortunately, they can't get a video_app_install banner ad to confirm this. With this, would it be possible for you to provide a Charles log (see instruction here) capturing the ad which triggers the issue? The requested Charles will enable us to replicate the behavior in our test app environment (by trafficking the creative in the test network).

Regards,
Google Logo
Teejay Wennie Pimentel
Mobile Ads SDK Team
 


ref:_00D1U1174p._5004Q2HAFuR:ref

vin...@gmail.com

unread,
Jul 12, 2021, 2:31:10 AM7/12/21
to Google Mobile Ads SDK Developers
Hi,

Team should force video_app_install as described here:

   Bundle extras = new Bundle();
  extras
.putString("ft_ctype", "video_app_install");

  AdRequest request = new AdRequest.Builder()
         
.addNetworkExtrasBundle(AdMobAdapter.class, extras)
         
.build();


Br,
Gabor

Mobile Ads SDK Forum Advisor

unread,
Jul 12, 2021, 5:54:52 AM7/12/21
to vin...@gmail.com, google-adm...@googlegroups.com
Hi Gabor,

Thank you for pointing this out. I've tried your suggestion and was able to load a video_app_install ad on my end. However, I can't seems to trigger the alert the shows the current ad size (just like on the screen recording the you provided). Do I need to uncomment something in your sample project to enable this?

vin...@gmail.com

unread,
Jul 14, 2021, 7:29:29 AM7/14/21
to Google Mobile Ads SDK Developers
Hi,

I think I have shared the source several times, so not sure which version are you using, but this is the addOnGlobalLayoutListener of adView in Main.java:

adView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
                    @Override
                    public void onGlobalLayout() {
                        if ((adView.getTag() != null) && (adView.getTag() instanceof Boolean)) {
                            int lAdHeight = adView.getHeight();
                            int lAdWidth = adView.getWidth();
                            int screen_height = Resources.getSystem().getDisplayMetrics().heightPixels;


                            Toast.makeText(myContext, "lAdHeight = " + lAdHeight + "\n" +
                                    "screen_height = " + screen_height, Toast.LENGTH_SHORT).show();


                            Log.d(TAG, "Ads: Google banner: Width x Height=" + lAdWidth + " x " + lAdHeight);
                            Log.d(TAG, "Ads: Screen_height=" + screen_height);

                            if ((0 != lAdHeight) && (0 == viewPager.getPaddingBottom())
                                    && (lAdHeight < (screen_height * 0.16))) {
                                viewPager.setPadding(0, 0, 0, lAdHeight);
                            }
                        }
                    }
                });



Note, that this  (lAdHeight < (screen_height * 0.16)) condition is my current workaround (and I have the Toast commented out in production version), so screen will not be messed up, but the Toast will show that first the lAdHeightis is  abnormally high and then it is normalized.

Br,
Gabor

Mobile Ads SDK Forum Advisor

unread,
Jul 15, 2021, 12:10:58 AM7/15/21
to vin...@gmail.com, google-adm...@googlegroups.com
Hi Gabor,

Thank you for getting back to us. I was able to repro the behavior on my end. With this, let me raise this to the team (including the reports and discussion thus far) once again for further investigation. We'll update this thread the soonest the team provide their feedback.

vin...@gmail.com

unread,
Nov 19, 2021, 4:05:46 AM11/19/21
to Google Mobile Ads SDK Developers
Hi,

Do you have any news about this issue? Ads version 20.5.0 has been released yesterday, but I still can not see the correction in the release notes.

Br,
Gabor

Mobile Ads SDK Forum Advisor

unread,
Nov 19, 2021, 6:22:13 PM11/19/21
to vin...@gmail.com, google-adm...@googlegroups.com
Hi Gabor,

Thank you for reaching out to us again. I was able to look at this and see that there has been no updates at this time. Once we hear something back we will be certain to pass it along.

Regards,
Google Logo
William Pescherine
Mobile Ads SDK Team
 


ref:_00D1U1174p._5004Q2HAFuR:ref

Mobile Ads SDK Forum Advisor

unread,
Jun 1, 2023, 9:54:41 AM6/1/23
to google-adm...@googlegroups.com, vin...@gmail.com
Hi Gabor,
 

This is likely a creative issue that the height is temporarily 1900 pixels. But the behavior shown in the video of the ad moving to the top of the screen looks related to the publisher adding a global layout listener and trying to set padding:

adView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
                @Override
                public void onGlobalLayout() {
                    if ((finalAdView.getTag() != null) && (finalAdView.getTag() instanceof Boolean)) {
                        int lAdHeight = finalAdView.getHeight();

                        if (viewPager != null) {
                            if ((0 != lAdHeight) && (0 == viewPager.getPaddingBottom()))
                                viewPager.setPadding(0, 0, 0, lAdHeight);
                        } else if (padding != null) {
                            if ((0 != lAdHeight) && (0 == padding.getPaddingBottom()))
                                padding.setPadding(0, 0, 0, lAdHeight);
                        }
                    }
                }
            });

You were using an anchored adaptive banner, whose WebView size does not change once the ad is loaded. If the ad height were to change, it would only affect the pixels inside of the AdView size defined (e.g. something like 360x60). You could avoid the flicker by not changing padding in their view pager around the ad.

Thanks,
Jill
Google Mobile Ads SDK Team



ref:_00D1U1174p._5004Q2HAFuR:ref
Reply all
Reply to author
Forward
0 new messages