Search code examples
androidadmobruntime-erroradstimeoutexception

How can I show ads and it gives me this error


My Admob ads not showing, I got this error

E/Ads: Error waiting for future.
    java.util.concurrent.TimeoutException
        at java.util.concurrent.FutureTask.get(FutureTask.java:177)
        at com.google.android.gms.ads.internal.util.future.g.a(:com.google.android.gms@16089017@16.0.89 (040306-239467275):12)
        at com.google.android.gms.ads.cache.l.a(:com.google.android.gms@16089017@16.0.89 (040306-239467275):5)
        at com.google.android.gms.ads.nonagon.signals.gmscore.q.call(Unknown Source)
        at java.util.concurrent.FutureTask.run(FutureTask.java:237)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
        at java.lang.Thread.run(Thread.java:818)
<com.google.android.gms.ads.AdView
    android:id="@+id/adView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_centerHorizontal="true"

    android:layout_gravity="center_horizontal"
    ads:adSize="BANNER"
    ads:adUnitId="@string/banner_ad_unit_id"
    />

//java code MobileAds.initialize(HomeActivity.this, getString(R.string.app_ad_unit_id));

    mAdView = findViewById(R.id.adView);
    AdRequest adRequest = new AdRequest.Builder().build();
    mAdView.loadAd(adRequest);

Solution

  • That means request of ads is time out because of less ads.If you want to show your ads make many time request to load ads(put your request code into for loop and make loop in 1000 times)in this case ads may be load.I also make this type code and ads can Load.

    But make sure you first add test id in your code because of in test case only ads is give to testing ads if you are show original ads to make your project live in play store.So,make sure to add test id in your code.

    If crash your app it means some mistake in your code So,if crash your app please put your code.

    I hope this can help You!

    Thank You.