Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"E/Ads: Error waiting for future" error when testing AdMob with emulator

Tags:

android

admob

I followed all required procedures to test AdMob on emulator but I'm having following error on the log:

E/Ads: Error waiting for future.
   java.util.concurrent.ExecutionException: java.util.concurrent.TimeoutException
       at com.google.android.gms.internal.ads.zzaoj.get(Unknown Source:35)
       at com.google.android.gms.internal.ads.zzano.zza(Unknown Source:19)
       at com.google.android.gms.internal.ads.zzafn.zza(Unknown Source:621)
       at com.google.android.gms.internal.ads.zzafn.zzb(Unknown Source:6)
       at com.google.android.gms.internal.ads.zzafp.run(Unknown Source:4)
       at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:457)
       at java.util.concurrent.FutureTask.run(FutureTask.java:266)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
       at java.lang.Thread.run(Thread.java:764)
    Caused by: java.util.concurrent.TimeoutException
       at com.google.android.gms.internal.ads.zzans.run(Unknown Source:4)
       at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:457)
       at java.util.concurrent.FutureTask.run(FutureTask.java:266)
       at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162) 
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636) 
       at java.lang.Thread.run(Thread.java:764) 
W/Ads: There was a problem getting an ad response. ErrorCode: 0
W/Ads: Failed to load ad: 0

XML Code as follow:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_height="match_parent"
android:layout_width="match_parent"
tools:context=".MainActivity">

<TextView android:text="Hi"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content" />

<com.google.android.gms.ads.AdView
  xmlns:ads="http://schemas.android.com/apk/res-auto"
  android:id="@+id/adView"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:layout_centerHorizontal="true"
  android:layout_alignParentBottom="true"
  ads:adSize="BANNER"
  ads:adUnitId="@string/banner_id">
</com.google.android.gms.ads.AdView>

</RelativeLayout>

The Activity Code is:

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;
import com.google.android.gms.ads.MobileAds;

public class MainActivity extends AppCompatActivity {

  private AdView mAdView;

  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);

      MobileAds.initialize(this,
              getResources().getString(R.string.app_ad_id));
      mAdView = findViewById(R.id.adView);
      AdRequest adRequest = new AdRequest.Builder()
        .addTestDevice(AdRequest.DEVICE_ID_EMULATOR).build();
    mAdView.loadAd(adRequest);
  }
}

I've tried to lower play-services-ads to version 12 in dependencies implementation, made sure permissions added to manifest, updated google service play and android images on the Android studio to latest update; also made sure that my account is active on AdMob and adUnits are active, yet still having same issue Thanks in advance for your help

like image 938
AstroMan Avatar asked May 15 '18 08:05

AstroMan


1 Answers

This is what google says I had that problem way back ! I solved it by waiting! and also it will not show live ads it will just give you a dummy add of admob just to tell that it is working!

in simple words!

"It could be that you have only recently created a new Ad Unit ID and requesting for live ads. It could take a few hours for ads to start getting served if that is that case. If you are receiving test ads then your implementation is fine. Just wait a few hours and see if you are able to receive live ads then. If not, can send us your Ad Unit ID for us to look into."

so basically you have to wait for a few hours

CHECK the LINK for resource that I talked about from GOOGLE

IF THE PROBLEM STILL PRESISITS

then do these one by one and check the app

  1. Try checking your UNIT ID maybe that's wrong

  2. Try checking the package name you provided is the same on the admob side

  3. try testing by the emulator by telling the admob to test on emulator using this

    AdRequest adRequest = new AdRequest.Builder().addTestDevice(your device id) //When you testing on emulator .addTestDevice(AdRequest.DEVICE_ID_EMULATOR).build();

4:check your app's manifest has that metaTag where you tell about google play version

enter image description here

CHECK THIS THREAD FOR MORE TIPS

like image 54
M.Rizwan Avatar answered Nov 14 '22 14:11

M.Rizwan