简体   繁体   English

Admob广告给出错误代码2(不显示)

[英]Admob ads giving error code 2 (not displaying)

I'm trying to make a basic libgdx app and the ads are not being displayed. 我正在尝试制作一个基本的libgdx应用程序,并且没有显示广告。 I'm following these guides: https://developers.google.com/android/guides/setup 我正在遵循以下指南: https : //developers.google.com/android/guides/setup

https://developers.google.com/admob/android/eclipse https://developers.google.com/admob/android/eclipse

https://github.com/libgdx/libgdx/wiki/Admob-in-libgdx https://github.com/libgdx/libgdx/wiki/Admob-in-libgdx

The code is very basic, just the one copied from the libgdx guide. 该代码非常基础,只是从libgdx指南中复制的代码。 The code works but the ads are not being displayed. 该代码有效,但未显示广告。

错误代码2 libgdx

Disable your Ad blocker. 禁用广告拦截器。 Make sure you don't have an app like adBlock installed. 确保没有安装adBlock之类的应用。

Anyway, that error means "Timed out waiting for ad response", so check your Internet connection and try changing from Wi-Fi to Mobile Network 无论如何,该错误表示“等待广告响应超时”,因此请检查您的Internet连接并尝试从Wi-Fi更改为移动网络

In my case, Error Code 2 was due to a stupid mistake. 就我而言,错误代码2是由于一个愚蠢的错误。 I was using the same code to initialize AdMobs and my Ad unit. 我使用相同的代码初始化AdMobs和广告单元。 Both codes look similar and so are easy to be confused with each other. 两种代码看起来相似,因此很容易彼此混淆。

Once solved, the code changed to 0, so, suspecting that my account wasn't ready yet, i used the test ID for interstitial ads and it worked like a charm. 解决后,代码更改为0,因此,怀疑我的帐户尚未准备好,因此我将测试ID用于插页式广告,它的工作原理很吸引人。

you should try using the test device code, like this: 您应该尝试使用测试设备代码,如下所示:

ActivityMainBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_main);
AdRequest adRequest = new AdRequest.Builder().addTestDevice("id_shown_in_logcat_when_you_debug").build();
binding.adViewBanner.loadAd(adRequest);

if that works, then you need to take a look at your admob account and see if it shows an error. 如果可行,则需要查看您的admob帐户,看看它是否显示错误。 For example, with mine it said I needed to link the app in the play store. 例如,我说它需要链接Play商店中的应用程序。

if that doesn't work, then you've got another problem 如果那不起作用,那么您还有另一个问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM