Home Features Docs Blog Support GitHub

AdMob and LibGDX Demo Project

Dear MOE Community

In the past days, I have been trying to get a MOE project with LibGDX working that uses the Google Admob SDK with bindings.
Since there was no straightup tutorial and helpful documentation (I suspect that this gets fixed with the MOE 2.0 release), I got my information from various GitHub pages and forum entrys.

Some links that helped me:

In the end, I got a working demo project (you have to tap on the screen to show/hide the ad).
MOE Version 1.3.6, LibGDX Version 1.9.6

Feel free to use my code!

Best regards,

David Wernhart

Dear @wernimaster,

thank you for the example app to use AdMob with LibGDX.

Best Regards,

Hi David,

I’ve tried to adopt your above admobtest code on my environment and finally get it running on my device without any error but no banner ads was shown. I can only see the badlogic logo displayed with the red background.

My environment:
Mac OS 10.11.6
Android Studio 3.0
Xcode 7.3.1
gdxVersion = ‘1.9.7’

I would like to share my code but I’m new to GitHub and still struggling how to upload folders of codes or create folder on GitHub manually. At the moment, I’ve uploaded a few files at the root level at the URL:

Any suggestion is appreciated. Thanks in advance.

Best regards,
Herman Tse

Hey Herman,

Have you tried tapping on the screen with the demo project open?
The ad is supposed to toggle on and of with tapping.

Hope that helps!

Best regards,

Hi David,

Thanks for your prompt reply.

I tried tapping on the screen and receive Gdx.app.log message indicated ‘showing’ or ‘hiding’ of ads but cannot see any visual changes on the screen.

I managed to upload my complete code onto GitHub as below URL:

Best regards,

… and I’m using framework GoogleMobileAdsSdkiOS-7.24.1

Best regards,

Hi David,

I solved it! I connected the device for testing and thus forget to turn on network (i.e. wifi connection). I turned on wifi and started the app and saw the test banner now! Problem solved!

Thanks for your help and attention anyway!

Best regards,

Nice to hear that this worked for you!
Sometimes the most trivial problems consume the most of your time.

Best regards,

Hi David,

Any sample code for Interstitial ads. I tried but can only display once and the interstitialDidDismissScreen is not called. In there I tried to re-alloc the GADInterstitial and make the ads load.

Best regards,

Hey Herman,

I solved the problem with loading the ad with a recursive call of an initialization method, like that:

initialization method:

public void createAdmobInterstitial() {
admobInterstitial = GADInterstitial.alloc().initWithAdUnitID(admobAdId);
        admobInterstitial.setDelegate(new GADInterstitialDelegate() {
            public void interstitialDidReceiveAd(GADInterstitial ad)
                Gdx.app.log("admob","interstitial received an ad");
            public void interstitialDidDismissScreen(GADInterstitial ad) {
                Gdx.app.log("admob","interstitial did dismiss screen");

        GADRequest request = GADRequest.request();

        Gdx.app.log("admob","new interstitial initialized");

actual method to show the interstitial:

public void showAdmobInterstitial(){
        if(admobInterstitial.isReady()) {
            Gdx.app.log("admob", "is presenting interstitial");

            Gdx.app.log("admob", "interstitial is not ready yet");

hope that helps!

Best regards,


Hi David,

Thanks for your thoughts.

I based on your thoughts and made a twist and solved the problem:

I have similar initialization method but without the setDelegate call.

In actual show method, I made use of the ‘not ready’ else clause to call the initialization method. Next time the show method is called will display the interstitial ads.

This way I avoid define a recursive method.

Thanks for pointing out the right direction.

Best regards,


Thanks for taking your time of creating and sharing this example. I have cloned it but got into trouble when trying to build it. The problem is that in the IOSLauncher class there is this call within the createApplication method:

return new IOSApplication(new MyGdxGame(), config);

But MyGdxGame constructor is actually declared as follows:

public MyGdxGame(adDelegate ads)

There’s no constructor without arguments in that class, thus I’m getting this compiler error:

error: constructor MyGdxGame in class MyGdxGame cannot be applied to given types;
required: adDelegate
found: no arguments
reason: actual and formal argument lists differ in length