为什么我的应用无法显示横幅广告? [英] Why can't I display banner ads on my app?

查看:30
本文介绍了为什么我的应用无法显示横幅广告?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我的第一个应用上显示横幅广告,我使用的横幅是自适应横幅.

I am trying to display banner ads on my first app, the banner Im using is the Adaptive Banner.

我在 admob 上制作横幅 3 周以来,测试广告工作正常,但是当我尝试用我的横幅单元 ID 替换测试横幅单元 ID 时,我的应用中没有显示广告,我也尝试将我自己的设备设置为测试设备,我发现测试广告也运行良好,我发现的错误代码是 3 无填充),我也尝试使用模拟器在其他设备上运行我的应用程序,但我没有看到广告同样,我还尝试了一些关于此主题的解决方案无法加载广告:3 但没有任何改变.

I have made my banner on admob since 3 weeks and the test ads are working fine but when I try to replace the test banner unit id with my banner unit id, Ads are not being displayed on my app, I also tried to set my own device as a test device and I found the test ads working well too, the error code I found is 3 No fill), I also have tried to run my app on other devices using the emulator and I didn't see ads as well, I also have tried some solutions I found on this topic failed to load ad : 3 but nothing changed.

我不得不提到我收到了一封来自 Admob 的电子邮件,说我的帐户已获批准,并且我已添加了我的付款信息(付款方式除外,因为它不允许我在帐户中获得 100 美元之前添加),我还没有在 Play 控制台上创建帐户.

I got to mention that I have received an email from Admob saying that my account has been approved and I have added my Payment information (except the payment method because it's not allowing me to add until I get 100 dollars on the account), I also didn't make an account on the Play console yet.

这是展示广告的代码:

public void displayAds()
{
    adView = new AdView(getApplicationContext());

    AdSize adSize = getAdSize();

    adView.setAdSize(adSize);

    adView.setAdUnitId(ADAPTIVE_BANNER_AD_UNIT_ID);

    adView.setAdListener(new AdViewListener());

    frameLayout.addView(adView);

    FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT,
            FrameLayout.LayoutParams.WRAP_CONTENT);

    params.gravity = Gravity.BOTTOM;

    adView.setLayoutParams(params);
    

 /* RequestConfiguration requestConfiguration =
    new RequestConfiguration.Builder().setTestDeviceIds(Arrays.asList        ("4D873959D076ACA64E5CE1643BC96B09")).build();

    MobileAds.setRequestConfiguration(requestConfiguration);*/

    for (int i = 0; i < 5000; i++) {

        AdRequest adRequest = new AdRequest.Builder().build();

        adView.loadAd(adRequest);
    }
  }

 public AdSize getAdSize()
{
    Display display = getWindowManager().getDefaultDisplay();

    DisplayMetrics outMetrics = new DisplayMetrics();

    display.getMetrics(outMetrics);

    float widthPixels = outMetrics.widthPixels;

    float density = outMetrics.density;

    int adWidth = (int) (widthPixels/density);

    Log.d("adWidth",String.valueOf(adWidth));

    return AdSize.getCurrentOrientationAnchoredAdaptiveBannerAdSize(this,adWidth);
}

这是我在 Logcat 上收到的 LoadAdErrorMessage 和 LoadAd errorCode:

And here is the LoadAdErrorMessage and LoadAd errorCode that I receive on the Logcat:

2020-10-08 08:59:17.130 29413-29413/com.example.naturesounds D/LoadAdErrorMessage: No ad config.
2020-10-08 08:59:17.130 29413-29413/com.example.naturesounds D/LoadAdErrorCode: 3

推荐答案

这是因为它还没有发布.请这样做以进行测试.发布前更改广告ID并发布.

This is because it is still before release. Please do it for testing. Change the advertisement ID before release and release it.

这篇关于为什么我的应用无法显示横幅广告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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