在模拟器中显示插页式广告时出现超时异常

时间:2017-11-22 06:38:28

标签: android admob interstitial

我正在尝试在模拟器中显示非页内广告测试广告。每次当我尝试显示时我都会收到错误说"插页式广告没有加载"以及例外情况。

java.util.concurrent.ExecutionException: java.util.concurrent.TimeoutException
                                                  at com.google.android.gms.internal.zzajy.get(Unknown Source:32)
                                                  at com.google.android.gms.internal.zzajg.zza(Unknown Source:19)
                                                  at com.google.android.gms.internal.zzabh.zza(Unknown Source:700)
                                                  at com.google.android.gms.internal.zzabh.zzb(Unknown Source:4)
                                                  at com.google.android.gms.internal.zzabj.run(Unknown Source:5)
                                                  at com.google.android.gms.internal.zzagn.call(Unknown Source:2)
                                                  at com.google.android.gms.internal.zzago.run(Unknown Source:9)
                                                  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.zzajk.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) 

我宣布广告如下。

 private void ad() {
    mInterstitialAd = new InterstitialAd(this);
    mInterstitialAd.setAdUnitId("ca-app-pub-3940256099942544/1033173712");
    mInterstitialAd.loadAd(new AdRequest.Builder().build());
 }

private void showInterstitial() {
     mInterstitialAd.setAdListener(new AdListener() {
        public void onAdLoaded() {
            if (mInterstitialAd.isLoaded()) {
                mInterstitialAd.show();
                AdRequest adRequest = new AdRequest.Builder().build();
                mInterstitialAd.loadAd(adRequest);
            }
        }
    });
}

每当我想显示广告时,我都会调用showInterstitial()。我只尝试使用mInterstitialAd.show()但未展示广告。这有什么不对?我也试过没有adlistener。

我如何展示广告

   movie.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    showInterstitial();
                    Intent s = new Intent(UserProfile.this,moviesearchrequest.class);
                    s.putExtra("from","wanted");
                    startActivity(s);
                    overridePendingTransition(R.anim.slide_in_up, R.anim.slide_out_up);
                }
            });

0 个答案:

没有答案