Window Leaked in Collapsible banner ads.

231 views
Skip to first unread message

Rana

unread,
Mar 25, 2024, 12:07:59 PM3/25/24
to Google Mobile Ads SDK Developers
I'm getting this error message when close the activity without collapsing the Collapsible banner ads. android.view.WindowLeaked: Activity com.notificationlist.NotificationDetailsActivity has leaked window android.widget.PopupWindow$PopupDecorView{3f375c6 V.E...... R......D 0,0-720,724} that was originally added here                at android.view.ViewRootImpl.<init>(ViewRootImpl.java:841)                at android.view.ViewRootImpl.<init>(ViewRootImpl.java:821)                at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:399)                at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:109)                at android.widget.PopupWindow.invokePopup(PopupWindow.java:1586)                at android.widget.PopupWindow.showAtLocation(PopupWindow.java:1348)                at android.widget.PopupWindow.showAtLocation(PopupWindow.java:1314)                at com.google.android.gms.ads.internal.gmsg.aq.a(:com.google.android.gms.policy_ads_fdr_dynamite@240304709@240304704034.602821767.602821767:1389)                at com.google.android.gms.ads.internal.webview.r.u(:com.google.android.gms.policy_ads_fdr_dynamite@240304709@240304704034.602821767.602821767:52)                at com.google.android.gms.ads.internal.webview.r.e(:com.google.android.gms.policy_ads_fdr_dynamite@240304709@240304704034.602821767.602821767:100)                at com.google.android.gms.ads.internal.webview.aj.run(:com.google.android.gms.policy_ads_fdr_dynamite@240304709@240304704034.602821767.602821767:25)                at android.os.Handler.handleCallback(Handler.java:938)                at android.os.Handler.dispatchMessage(Handler.java:99)                at m.axc.a(:com.google.android.gms.policy_ads_fdr_dynamite@240304709@240304704034.602821767.602821767:1)                at com.google.android.gms.ads.internal.util.f.a(:com.google.android.gms.policy_ads_fdr_dynamite@240304709@240304704034.602821767.602821767:2)                at m.axc.dispatchMessage(:com.google.android.gms.policy_ads_fdr_dynamite@240304709@240304704034.602821767.602821767:1)                at android.os.Looper.loop(Looper.java:255)                at android.app.ActivityThread.main(ActivityThread.java:8212)                at java.lang.reflect.Method.invoke(Native Method)                at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:632)                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1049) This is my full Collapsible banner ads code
<FrameLayout
android:id="@+id/ad_view_containerndetails"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_alignParentBottom="true"
android:layout_marginTop="1dp"
/>
private AdView adView; private FrameLayout adContainerView; private boolean initialLayoutComplete = false; iniadmobsdk(); private void iniadmobsdk() { adContainerView = findViewById(R.id.ad_view_containerndetails); adView = new AdView(this); adContainerView.addView(adView); adContainerView.getViewTreeObserver().addOnGlobalLayoutListener( new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { if (!initialLayoutComplete) { initialLayoutComplete = true; loadBanner(); } } }); } private void loadBanner() { adView.setAdUnitId(getString(R.string.notification_details_collapsible_banner)); AdSize adSize = getAdSize(); adView.setAdSize(adSize); Bundle extras = new Bundle(); extras.putString("collapsible", "bottom"); extras.putString("collapsible_request_id", UUID.randomUUID().toString()); AdRequest adRequest = new AdRequest.Builder() .addNetworkExtrasBundle(AdMobAdapter.class, extras).build(); adView.loadAd(adRequest); } private AdSize getAdSize() { Display display = getWindowManager().getDefaultDisplay(); DisplayMetrics outMetrics = new DisplayMetrics(); display.getMetrics(outMetrics); float density = outMetrics.density; float adWidthPixels = adContainerView.getWidth(); if (adWidthPixels == 0) { adWidthPixels = outMetrics.widthPixels; } int adWidth = (int) (adWidthPixels / density); return AdSize.getCurrentOrientationAnchoredAdaptiveBannerAdSize(this, adWidth); } @Override public void onPause() { if (adView != null) { adView.pause(); } super.onPause(); } @Override public void onResume() { super.onResume(); if (adView != null) { adView.resume(); } } @Override protected void onDestroy() { if (adView != null) { adView.destroy(); } super.onDestroy(); }

Mobile Ads SDK Forum Advisor

unread,
Mar 25, 2024, 2:43:59 PM3/25/24
to masud....@gmail.com, google-adm...@googlegroups.com

Hi Rana,

Thank you for contacting the Mobile Ads SDK Support team.

Please refer to the sample application for the implementation and guide for collapsible banner ads. When implementing ads in your application, it is very important to follow AdMob Policies, as well as Implementation Guidelines to avoid any issues.  Kindly double-check your implementation so that Ads load and show as expected. You may refer to Banner Implementation Guidelines, as well as the Recommended and Disallowed implementation guidance for further reference. Also, can you confirm whether you can reproduce the mentioned issue in our Google Banner example as well? If yes, then provide the following information privately for further investigation:

  • app ID
  • ad unit ID
  • Screenshot(s) or recording(s) captured in memory profiler that show window leak
  • Sample project reproducing the issue

You can provide the following details via reply privately to the author option or directly provide it to the link below.

If the file(s) you are looking to share are less than 25mb in total you can attach them to this case on your next reply. If you are having trouble attaching your file to this case or if your file(s) are larger than 25mb, you can share your files with me by performing the following steps:

1. Navigate to

https://docs.google.com/forms/d/e/1FAIpQLSfkAiXMeYP-fw1W3Z-tT9uwmATEKO5X6S-th0gR2ezdKaaqfg/viewform?usp=pp_url&entry.400550049=Mobile+Ads+SDK&entry.460850823=5004Q00002s0DD9QAM&entry.80707362=00228611

2. Fill out all fields, and attach your file(s).

3. Please reply back on this thread when you have uploaded your file(s). Please do not share this link. 

This message is in relation to case "ref:!00D1U01174p.!5004Q02s0DD9:ref" (ADR-00228611)

Thanks,
 
Google Logo Mobile Ads SDK Team


Reply all
Reply to author
Forward
0 new messages