问题
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.
回答1:
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
回答2:
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.
回答3:
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
来源:https://stackoverflow.com/questions/32084134/admob-ads-giving-error-code-2-not-displaying