当前位置: 首页 > 知识库问答 >
问题:

AdMob真实广告不显示

杨凯旋
2023-03-14

我的广告不显示。

我正在开发一个需要广告的应用程序。目前正在进行测试,我在Google Play console的内部测试轨道上对该应用程序进行封闭测试。因此,我无法将其链接到Admob中Play store中的应用程序。

所以,为了测试它们,我一直是示例测试广告单元,特别是间隙广告和奖励视频广告。它们加载良好。

今天,我决定切换到生产广告,因为我想发布该应用程序。所以,我为奖励和互动创建了新的广告单元。将测试广告ID单元替换为生产广告单元ID。我看到“广告加载失败:0”。

我没有使用示例广告单元,而是尝试将我的设备设置为测试设备。我看到下面的日志

I/Ads:该请求由测试设备发送。I/Ads:Ad未能加载:0

我不确定问题是什么。我仍在内部测试轨道中。有问题吗?制作广告是否仅在链接到Google Play中的应用程序时才有效?

请让我知道我哪里出错了。请参阅Admob广告单元的附加图像

代码如下所示:

显示xml:

    <meta-data
         android:name="com.google.android.gms.ads.APPLICATION_ID"
         android:value="ca-app-pub-xxxxxxxxxxxxxxxx~xxxxxxxxxx" />

build.gradle:

    implementation 'com.google.android.gms:play-services-ads:19.2.0'

实施AdMob:

    @Override
    protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      //Rest of the code


   MobileAds.initialize(this, new OnInitializationCompleteListener() {
      @Override
      public void onInitializationComplete(InitializationStatus initializationStatus) {
         Log.w(TAG, " initialized mobile ad");
      }
   });

   List<String> testDeviceIds = Arrays.asList("xxxxxxxxxxxxxxxxxxxxxxxxx");
       RequestConfiguration configuration =
       new RequestConfiguration.Builder().setTestDeviceIds(testDeviceIds).build();
       MobileAds.setRequestConfiguration(configuration);

   }

   public void loadInterstitialAd(){
   mInterstitialAd = new InterstitialAd(this);
   this.rewardedAd = new RewardedAd(this, "ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxx");
   //mInterstitialAd.setAdUnitId("ca-app-pub-3940256099942544/1033173712");
   mInterstitialAd.loadAd(new AdRequest.Builder().build());


   mInterstitialAd.setAdListener(new AdListener() {
   @Override
   public void onAdLoaded() {
     if (mInterstitialAd.isLoaded()) {
        mInterstitialAd.show();
     } else {
        Log.d("TAG", "The interstitial wasn't loaded yet.");
     }
   }

  @Override
  public void onAdClosed() {
     Log.w(TAG, "Interstitial ad cloed ");
     onInterstitialshowed();
  }
    });
  }


  public void loadRewardedAd(){
   this.rewardedAd = new RewardedAd(this, "ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxx");
  //this.rewardedAd = new RewardedAd(this, "ca-app-pub-3940256099942544/5224354917");
  RewardedAdLoadCallback callback = new RewardedAdLoadCallback(){
  @Override
  public void onRewardedAdFailedToLoad(int i) {
     super.onRewardedAdFailedToLoad(i);
  }

  @Override
  public void onRewardedAdLoaded() {
     super.onRewardedAdLoaded();
     showRewardedAd();
  }
  };
  this.rewardedAd.loadAd(new AdRequest.Builder().build(), callback);
  }

     public void showRewardedAd(){
     if(rewardedAd.isLoaded()){
     RewardedAdCallback callback = new RewardedAdCallback() {
     @Override
     public void onUserEarnedReward(@NonNull RewardItem rewardItem) {
        Log.w(TAG, "onUserEarnedReward");
     }

     @Override
     public void onRewardedAdOpened() {
        super.onRewardedAdOpened();
        Log.w(TAG, "OnRewardAdOpened");
     }

     @Override
     public void onRewardedAdClosed() {
        super.onRewardedAdClosed();
        onRewardedAdLoadedOnClick();
     }

     @Override
     public void onRewardedAdFailedToShow(int i) {
        super.onRewardedAdFailedToShow(i);
        Log.w(TAG, "onRewardedAdFailedToShow");
     }
  };
  this.rewardedAd.show(this, callback);
  }else{
  Log.i(TAG, "Ad not loaded");
  }
 }

共有1个答案

欧阳正卿
2023-03-14

我在SDK ANDROID LEVEL 30上也遇到了同样的问题。当我把它改成SDK ANDROID LEVEL 29时,广告显示了这一点。

 类似资料:
  • 我已经在我的手机上测试了广告功能。只显示测试广告。当我用我从AdMob得到的单位id替换时,真正的广告就不显示了。 问题出在哪里? 下面是我的代码: 对于我使用的xml 用于加载我使用的ad 在manifeast我有 ...。 但我的广告不加载在android设备上。测试广告运作良好。所有这些操作我都用了一个真实的装置。有什么需要帮忙的吗?

  • 我已经与Admob广告斗争了将近一周,我在互联网上搜索了所有可能的解决方案,但都没有奏效。我的Android应用程序不显示测试广告也不显示实时广告。这是日志: 我的测试间隙负载没有问题,带电的没有。横幅没有显示,测试的和带电的都没有显示。 这是我的xml AdView: 我在横幅上加了: 活动间隙是以这种方式加载的,它是有效的(测试一没有): 我尝试过的事情 > 使用 使用Firebase广告编译

  • 这是调试器在运行代码时输出的内容: 2018-11-07 22:12:42.806497-0600CoverMe[7740:78040]未能在(UITabBar)上设置(keyPath)用户定义的检查属性:[setValue: forUndecedKey:]:此类不符合密钥keyPath的键值编码。2018-11-07 22:12:42.901273-0600CoverMe[7740:78040]

  • 它在模拟器和真实设备上显示测试广告。但是当我把广告ID改成我的真实ID时,它就不起作用了。。我的应用程序也在AppStore中,但我没有推送更新。我只在Xcode中添加了AdMob,然后连接了真正的设备并在其上进行了测试。我必须将AdMob的最新更新发布到App Store才能看到真正的广告吗?我该怎么办?在推送更新之前,我想测试一下我的真实广告。。 (已填写付款明细)

  • 我的代码看起来与原始代码一模一样(https://developers.google.com/mobile-ads-sdk/docs/admob/fundamentals?hl=en#play)我确信我正确导入了所有内容,向我的AndroidManifest添加了元数据、活动和权限。 当我在我的设备上启动应用程序时,logcat 会给我以下内容: 找不到此Google Play服务资源和加载广告失

  • 我试图使用新的Google-service-libs在我的应用中设置AdMob广告。在Genymotion模拟器广告中一切看起来都很好。但他们没有像我的Galaxy Ace GT5830i和Android 2.3.6这样的真实设备。我不知道是什么问题。 下面是一些代码: XML: 我的Ad_Unit_Id以字符串形式保存。res/文件夹中的xml文件。 java语言: 如果您需要更多代码,请告诉我