Admob既不展示测试广告也不展示真实广告 [英] Admob does not show test ads nor real ads

查看:400
本文介绍了Admob既不展示测试广告也不展示真实广告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在Admob广告上苦苦挣扎了近一个星期,并且我在整个互联网上进行搜索以找到可能的解决方案,但没有任何效果。我的Android应用程序既不展示测试广告也不展示实时广告。这是日志:

I've been struggling with Admob ads for almost a week now and I searched all over the internet to find a possible solution but nothing worked. My Android application does not show test ads nor live ads. This is the log:

I/Ads: Updating ad debug logging enablement.
I/Ads: Starting ad request.
    SDK version: afma-sdk-a-v13280019.11910000.1
I/Ads: This request is sent from a test device.
W/Ads: Not retrying to fetch app settings
W/Ads: Update ad debug logging enablement as false
W/Ads: App does not have the required permissions to get location
    I/Ads: Trying mediation network: 
    I/Ads: Instantiating mediation adapter: com.google.DummyAdapter
    I/Ads: No fill from any mediation ad networks.
    I/Ads: Scheduling ad refresh 60000 milliseconds from now.
    W/Ads: Failed to load ad: 3

我的测试非页内广告加载没有问题,直播的却没有。标语没有显示,没有测试或现场直播。

My test interstitial loads with no problem, the live one doesn't. The banner does not show, not the test one nor the live one.

这是我的xml AdView:

This is my xml AdView:

<com.google.android.gms.ads.AdView
            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="ca-app-pub-3940256099942544/6300978111"> //test admob unit id
</com.google.android.gms.ads.AdView>

我在横幅上输入以下内容:

And I load the banner with:

     MobileAds.initialize(this, getString(R.string.app_id));
 adView1 = findViewById(R.id.adView);
AdRequest adRequest1 = new AdRequest.Builder().addTestDevice("my_test_device_id").build();
adView1.loadAd(adRequest1);

实时插页式广告以这种方式加载,并且可以正常工作(测试对象无效):

The live interstitial is loaded in this way, and it works (the test one does not):

final InterstitialAd mInterstitialAd = new InterstitialAd(this);
          mInterstitialAd.setAdUnitId("_live_ad_id");
          mInterstitialAd.loadAd(new AdRequest.Builder().addTestDevice("my_test_device_id").build());
          mInterstitialAd.setAdListener(new AdListener(){
              @Override
              public void onAdLoaded(){
                  mInterstitialAd.show();

              }
          });
          if (mInterstitialAd.isLoaded()) {
          } else {
              Log.d("TAG", "The interstitial wasn't loaded yet.");
          }

我尝试过的事情


  • 使用实现'com.google.android.gms:play-services-ads:15.0.1'编译gradle

按照firebase网站上的指南将firebase广告编译为gradle,并将firebase连接到我的admob帐户

compile gradle with firebase ads, following the guide in the firebase site and connecting firebase to my admob account

在相对线性布局中添加AdView

include the AdView inside a Relative and Linear Layout

更改广告尺寸

更改活动和布局

没有任何效果。据我了解的日志,该广告请求成功,但是admob目前没有要显示的广告。也许由于我的应用尚未投放而没有展示实时广告,但是为什么测试广告没有展示?为何只有实时插页式广告有效?我还认为可以禁用我的admob帐户,但该广告可以在我的其他应用程序上使用。

Nothing worked. From what I've understood my log say the ad request is successful but admob does not have ads to display at the moment. Maybe the live ads are not shown because my app is not live yet but why the test ads does not show? And why only the live interstitial ad work? I also thought my admob account could be disabled but the ads works on my other applications.

推荐答案

更改您的 ads:adUnitId = ca-app-pub-3940256099942544 / 6300978111 ads:adUnitId = your_banner_id

注意: ca-app-pub-3940256099942544 / 6300978111 其用于测试!

尝试将此代码用于横幅广告

try this code for banner

 MobileAds.initialize(this, getString(R.string.app_id));
 adView1 = findViewById(R.id.adView);
AdRequest adRequest1 = new AdRequest.Builder().addTestDevice("my_test_device_id").build();
adView1.loadAd(adRequest1);

对于InterstitialAd

For InterstitialAd

MobileAds.initialize(LoginActivity.this, getResources().getString(R.string.app_id));

        mInterstitialAd = new InterstitialAd(this);

         mInterstitialAd.setAdUnitId(getResources().getString(R.string.full_screen_ads_id));
            mInterstitialAd.loadAd(new AdRequest.Builder()
                    .build());
            mInterstitialAd.setAdListener(new com.google.android.gms.ads.AdListener() {
                @Override
                public void onAdLoaded() {
                    mInterstitialAd.show();
                    super.onAdLoaded();

                }
            });

这篇关于Admob既不展示测试广告也不展示真实广告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆