首次加载广告时,应用会自动关闭

时间:2016-12-24 15:40:40

标签: java android admob google-play-services ads

首次加载我的应用时,它不会加载广告并关闭。如果我在加载广告之前打开另一个活动,并返回主活动,则表示没有出现问题。

    W/Ads: Could not fetch ad response from ad request service.
       android.os.DeadObjectException
           at android.os.BinderProxy.transact(Native Method)
           at com.google.android.gms.ads.internal.request.ac.a(:com.google.android.gms.DynamiteModulesA:148)
           at com.google.android.gms.ads.internal.request.k.a(:com.google.android.gms.DynamiteModulesA:247)
           at com.google.android.gms.ads.internal.request.l.a(:com.google.android.gms.DynamiteModulesA:1221)
           at com.google.android.gms.ads.internal.util.promise.e.a(:com.google.android.gms.DynamiteModulesA:46)
           at com.google.android.gms.ads.internal.request.c.a(:com.google.android.gms.DynamiteModulesA:150)
           at com.google.android.gms.ads.internal.util.b.run(:com.google.android.gms.DynamiteModulesA:19)
           at com.google.android.gms.ads.internal.util.y.call(:com.google.android.gms.DynamiteModulesA:1055)
           at com.google.android.gms.ads.internal.util.z.run(:com.google.android.gms.DynamiteModulesA:75)
           at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:442)
           at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
           at java.util.concurrent.FutureTask.run(FutureTask.java:137)
           at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
           at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
           at java.lang.Thread.run(Thread.java:856)
W/Ads: There was a problem getting an ad response. ErrorCode: 0
W/Ads: Failed to load ad: 0
Disconnected from the target VM, address: 'localhost:8600', transport: 'socket'

以下是加载广告的代码:

    private void loadads_ (){
        Toast.makeText(MainActivity.this, " loading ads", Toast.LENGTH_SHORT).show();
        try {
            AdView adView = (AdView) findViewById(R.id.adView2);
            AdRequest adRequest = new AdRequest.Builder()
                    .setRequestAgent("android_studio:ad_template").build();
            adView.loadAd(adRequest);
        } catch (Throwable e){
            Toast.makeText(MainActivity.this, "erro loading ads", Toast.LENGTH_SHORT).show();
        }

我在添加广告之前创建了一个备份。这是正常的。

0 个答案:

没有答案