6

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

AstroMan
  • 61
  • 1
  • 10
  • FYI, the ads don't get displayed in emulator. only test ads are visible. You need to test it on real device – Masoom Badi May 15 '18 at 08:52
  • Thank you for your prompt reply, but as per Google Developers Series "Mobile Ads Garage #2" I should get test banner displayed in my emulator. https://youtu.be/h-FMndW2kHo?t=2m56s – AstroMan May 15 '18 at 08:57
  • @AstroMan Did you resolve this problem? – Son Truong Sep 30 '18 at 16:12
  • @SonTruong After reaching out with AdMob, I found that the problem with the emulator; thus I had to use my android mobile instead. – AstroMan Oct 01 '18 at 18:05

1 Answers1

2

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

Rizwan Atta
  • 3,222
  • 2
  • 19
  • 31
  • Thanks @Rizwan for your answer, I actually made the account just yesterday but I waited until it gets approved and I see it active and enabled in the AdUnits tab in my AdMob account, isn't that enough, or should I wait much longer? Appreciate your patience and support. – AstroMan May 15 '18 at 09:04
  • Also regarding the checklist you added, should the name of app on AdMob to be the package name on the Manifest? please clarify... – AstroMan May 15 '18 at 09:09
  • in manifest.xml of your application there should be this meta Tag present that I showed above – Rizwan Atta May 15 '18 at 10:49
  • and the package name you provided for the creation of admob ad UnitId and package name of your app should be the same! – Rizwan Atta May 15 '18 at 10:50
  • I added the meta tag to the app and changed the App name in AdMob to same package name of my app in manifest, but still have same issue here... – AstroMan May 15 '18 at 13:16
  • Any suggestions? – AstroMan May 15 '18 at 13:20