I am displaying a native ad in an Activity which has FragmentContainerView to display different fragments. But when I exit the app using back button, I am getting the following error
E/WindowManager: android.view.WindowLeaked: Activity com.status.statusdownload.views.MainActivity has leaked window com.google.android.gms.internal.ads.zzbft{4119d98 I.E...... ......I. 0,0-840,0} that was originally added here
at android.view.ViewRootImpl.<init>(ViewRootImpl.java:598)
at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:377)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:96)
at com.google.android.gms.internal.ads.zzcen.zzh(com.google.android.gms:play-services-ads@@19.8.0:53)
at com.google.android.gms.internal.ads.zzcdf.zzb(com.google.android.gms:play-services-ads@@19.8.0:134)
at com.google.android.gms.internal.ads.zzcel.onGlobalLayout(com.google.android.gms:play-services-ads@@19.8.0:108)
at com.google.android.gms.internal.ads.zzbbl.onGlobalLayout(com.google.android.gms:play-services-ads@@19.8.0:6)
at android.view.ViewTreeObserver.dispatchOnGlobalLayout(ViewTreeObserver.java:1056)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2629)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1722)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7621)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1029)
at android.view.Choreographer.doCallbacks(Choreographer.java:852)
at android.view.Choreographer.doFrame(Choreographer.java:787)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1014)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:235)
at android.app.ActivityThread.main(ActivityThread.java:7441)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
I have destroyed reference to native ad using as per the official documentation (https://developers.google.com/admob/android/native/start)
if (isDestroyed) {
unifiedNativeAd.destroy()
return@forNativeAd
}
Please help me solve this error.
The accepted answer is correct. But in case if someone doesn't know how should it look in the manifest:
<manifest>
...
<application>
...
<meta-data
android:name="com.google.android.gms.ads.flag.NATIVE_AD_DEBUGGER_ENABLED"
android:value="false" />
</application>
</manifest>
It looks like the issue is caused by the new native validator, when I disable the validator in my manifest file the error goes away. Since the validator is automatically disabled for release builds.
Disabling the validator using NATIVE_AD_DEBUGGER_ENABLED
in the manifest file fixes both these issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With