libGDX Trying to implement AdMob but can't get it to work

I’ve been busy going through a bunch of documentation and tutorials to figure out how to implement AdMob into my game, but no luck so far.

The LibGDX wiki documentation is a bit outdated and some of the code is simply not working https://github.com/libgdx/libgdx/wiki/Admob-in-libgdx
f.e. initializeForView doesn’t take in boolean values anymore , or the adView method can’t be used like this anymore:

 View gameView = initializeForView(new HelloWorld(this), false);

.... or 

  // Create and setup the AdMob view
        adView = new AdView(this, AdSize.BANNER, "xxxxxxxx"); // Put in your secret key here
        adView.loadAd(new AdRequest());

I also worked through the Google AdMob documentation (https://developers.google.com/mobile-ads-sdk/docs/admob/android/quick-start), but it isn’t very good aplicable to a LibGDX project.
I even tried just getting it running with AndroidStudio without using libgdx, but even that I didn’t get to work accordingly.

I tried to work around it, but after a full days of tryingI still haven’t been able to get any test ads on my android device when debugging on my device & any help would be more than welcome.

Can someone help me with this?
Does anyone know some more up to date info on how to set up AdMob in your libgdx project?


Here’s what my AndroidManifest.xml looks like: http://pastebin.java-gaming.org/f9d35261d1111
And here’s a version of my AndroidLauncher.java that I was hoping to show me some adds but it isn’t:http://pastebin.java-gaming.org/9d3563d11111e

Just don’t pass the boolean.

Also adrequest can no longer be instantiated like that, instead do :

AdRequest r = (AdRequest)  Adrequest.Builder().build() ; // you can method chain this as well,  so check that out,  casting might not be necessary; can't remember 

Yes, i tried both (see pastebin), byt thing is i simply don’t get it to run.

I’ll be working on it today and if i fugre it out I’ll show my code here later, but for now i could really use a working code example (one that’s working TODAY, using the latest SKD updates, etc.)

The code example in the google’s AdMob documentation is simply not working, nor is LibGDX’s.

Finally got something to work.

I used the code from the “updated” Libgdx AdMob documentation (commenting out cfg.useGL20;)and it works fine:

Link to my Stackoverflow post on this issue:

Haven’t got interstitial adds working yet.

Followed the documentation on the libgdx wiki for interstitial ads but can’t seem to get the actionResolver interface passed/working at line 89:

gameView = initializeForView(new AdTutorial(this), cfg);

(https://github.com/TheInvader360/tutorial-libgdx-google-ads/commit/0a5ea376d4eb92b8e87c13a03245adb40b53e811#diff-6be4dfe9bea01523ff90935a9a5545b6R85)

Got it to work. Not sure why I don’t have any porblems with passing the ActionResolver anymore…

For anyone having problems as well with incorporating interstatials following this tutorial:

  • in your AndroidLauncher remove cfg.useGL20 (not being used anymore)
  • change the texture that’s being refered to in AdTutorial.java to: texture = new Texture(Gdx.files.internal(“badlogic.jpg”)); (“newer” libgdx distribution use differnet filename+location)
  • take a good look at filelocation of the tutorialfiles in the git repo