简体   繁体   中英

Admob ads giving error code 2 (not displaying)

I'm trying to make a basic libgdx app and the ads are not being displayed. I'm following these guides: https://developers.google.com/android/guides/setup

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

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

The code is very basic, just the one copied from the libgdx guide. 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.

Anyway, that error means "Timed out waiting for ad response", so check your Internet connection and try changing from Wi-Fi to Mobile Network

In my case, Error Code 2 was due to a stupid mistake. I was using the same code to initialize AdMobs and my Ad unit. 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.

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. For example, with mine it said I needed to link the app in the play store.

if that doesn't work, then you've got another problem

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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