LibGDX and google-mobile-ads Robopods integration (iOS)

I just started porting my existing android game (word-hunter) to iOS and ran into a lot of troubles trying to make adMob works on iOS with libgdx and robovm, so I figure someone else might need this :)

You should probably already have an Interface in your libgdx core project to specify the actions correspond to the display of ads:

public interface AdsDisplayInterface{
   public void loadAd();
   public void showAd();

And your game constructor should expect an implementation of this interface as argument:

public class Game implements ApplicationListener {
   public AdsDisplayInterface _adsDisplay;

   public Game(AdsDisplayInterface adsDisplay){
      _adsDisplay = adsDisplay;

   public Game(){

      public void create() {

Now you can call _adsDisplay.loadAd() and _adsDisplay.showAd() anytime you want in your game, see this post for more details on how this works.

Now we want to create a class implementing this Interface in the platform where we want to display ads, in our case: iOS.

First we need to integrate the google-mobile-ads robopod binding (git repo).

Follow the instructions from the README in the git website and use either graddle or maven to add the binding.

I added compile “org.robovm:robopods-google-mobile-ads-ios:$roboVMVersion” in the dependencies of the project(“:ios”) in the main build.gradle of my libgdx projects, used ./gradlew eclipse and then imported the projects into Eclipse.

Another option if you don’t want to use graddle or maven is to directly grab the jar files you need (robopods-google-mobile-ads-ios-$robovmVersion.jar and robopods-google-apis-ios$robovmVersion.jar) from the robovm maven directory and add then to your ios project /lib folder (create it if necessary) and add both jar to the build bath.

Now we need to create an implementation of the AdsDisplayInterface in our ios project:

public class ViewController implements AdsDisplayInterface {
 private GADInterstitial interstitial;

 private GADInterstitial createAndLoadInterstitial() {
     //Ad Unit ID of your interstital, from your adMob account. Use the TEST one for now
     GADInterstitial interstitial = new GADInterstitial("ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxx");
     interstitial.setDelegate(new GADInterstitialDelegateAdapter() {
         public void didDismissScreen(GADInterstitial ad) {
             ViewController.this.interstitial = createAndLoadInterstitial();
     return interstitial;

 private GADRequest createRequest() {
     GADRequest request = new GADRequest();
     // To test on your devices, add their UDIDs here:
     return request;

 public void loadAds() {
     interstitial = createAndLoadInterstitial();

 public void showAds() {
     if (interstitial.isReady()) {
     } else {
         System.out.println("Interstitial not ready!");


I used this sample application and modified a couple of things to make it work with libgdx. If you need to add banners, check the sample and it should be quite straightforward.

Now we need to modify our IOSLauncher in the libgdx IOS application:

public class IOSLauncher extends IOSApplication.Delegate {

 private GADInterstitial interstitial;

 protected IOSApplication createApplication() {
     Words.setPlatformResolver(new DesktopResolver());

     IOSApplicationConfiguration config = new IOSApplicationConfiguration();
     return new IOSApplication(new Game(new ViewController()), config);

 public static void main(String[] argv) {
     NSAutoreleasePool pool = new NSAutoreleasePool();
     UIApplication.main(argv, null, IOSLauncher.class);

And now it should work :) Your IOS ad will show up whenever you call loadAd() then showAd() in your game.

Hopefully I didn’t forget any steps, otherwise let me know !


New puzzle game! Gem Hunter

I’ve just finished the development of a small game I wanted to do in my spare time, much simpler than my previous game but it’s still quite fun to play.


The game is obviously available for free on the google play store here: Gem Hunter

The game is quite simple, you try to line up rows/columns of the same color to make them dissapear and earn points, to do so, you can change a gem color by tapping on it, but when you do, a new gem appear on the board. Get as much points as you can before the board is full :)

As always, any feedback is welcome, I haven’t tested on all device yet :)

First major update to Word Hunter

It’s been a week since I published the first version of Word Hunter and it’s going quite well. The game is not perfect but I was able to get quite some feedback and act upon it :)

What’s new ?

  • 20 new levels (double of what was available before) with new gameplay mechanisms
  • New dragback mechanism: you can drag back on the previous letter to correct the word
  • 6 new achievements
  • Bug fix for the HTC One
  • Better handling of ads, they shouldn’t show up in game anymore

LVL 21 - New Cages       New gameplay mechanism

Word Hunter trailer !

I’ve created a trailer for Word Hunter !

It’s my first video recording/editing experience and it was quite interesting.

I recorded it using quick time and did all the video editing using iMovie. Both tools are available by default on all Mac Os installs (AFAIK)

  • Quick Time is fine for recording: the video quality is decent but not great and there is no option to hide the mouse during recording (but there is the option to show mouse clicks)
  • iMove is quite easy to pick up and quite frankly suits most of my needs as a beginner. It’s got a nice library of default effects which are quite nice. Really easy to add titles, transitions, effects and musics. Only downside is that you are limited to the transitions/titles available and can’t create your own. But this might be due to me being a total noob :)

Here it is :

The music is by Kevin McLeod at

I still have a lot to learn about video editing so I am willing to listen to all feedback :)

LibGDX and Google Play Game Service Integration

I have been hard working on Google Play Game integration in my upcoming game : Word Hunter and I am posting my finding heres. Hopefully it can help someone else :)

Configuring Google Play Game

Log on to the developer console (if you don’t already have an account, you will need to create one for 25$)

Select “Game Services” and follow the instructions to create a new game.

Some notes :

    • Use the debug certificate in your android sdk install folder
      • You will be able to test Google Play Game integration directly when you launch your application from Eclipse without having to sign it with your production certificate
      • But you will have to restart the process all over again once you want to push it to production (…)
    • Use your production certificate that you use to publish your application to google play
      • You will need to sign your APK using your production certificate (right click on your project -> Export as Android Application) and then install this APK on your device to test it
      • And you are done, you can simply publish the game when you are done and it will work

I went with solution #2 since I am publishing my game in Alpha state in Google play and I want my testers to be able to use it

  • DO NOT forget to add your testers email in the list of testers for the GAME, it is a different list than the application testers or even the Alpha testers
  • Do not bother trying to test Google Play Game with your developer account, even if it is marked as a tester, it just doesn’t work. Use another account.

Once you are done, you should get an application ID associated to your game, follow this documentation to make it available in your game (short version, create an ids.xml file in the android res/values folder and add this id in it as a string with name app_id). This is also where you will put the key for your leaderboards/achievements. You will also need to modify your manifest as indicated in the documentation.

Configuring the libGDX Core project

In your Core project, create an interface with all the actions that you want to be able to do from your game. The basis are :

  • Logon
  • Logoff
  • Send a score to the leaderboard
  • Unlock an achievement
  • Show the Score Leaderboard
  • Show the Achievements Screen

Pastebin code

Configuring the Android project

Once this is done, we need to do several things:

First follow the instructions to download the sample apps from here .

You should get the google-play-services-lib when you install the google play service SDK. Add it to your workspace and add it to your Android project as a library (right click on your android projects -> Properties)

From the BaseGameUtils projects, copy the class directly into your Android project.

Now we will modify the Android project MainActivity class.

First it needs to implement the previously created interface, as well as the GameHelper.GameHelperListener interface (from the GameHelper class we just copied) :

public class MainActivity extends AndroidApplication implements LeaderboardInterface, GameHelper.GameHelperListener

In this class, we will need to instantiate a GameHelper and implement the different methods specified in the Interface. Most of this code was inspired/copied from the BaseGameActivity available in the sample Android project.
Once this is done, we need to pass the MainActivity itself as an argument of the initialize method.

Here is the code

Possible improvements :

  • Show a toast when the unlockAchievement method is called by user is not logged in google play
  • Push scores and achievements right after login, in the onSignInSucceeded method

I noticed that by using this method, the Title Bar now appears in game. To solve this issue, simply add the following theme to your main activity in the manifest :


How to use it in game

In your main class in the core libGDX project (the one which implements ApplicationListener), create a variable of type GameServiceInterface and set it using the arguments passed in the constructor :

public class Game implements ApplicationListener {

public GameServiceInterface _leaderboard;

public Game(GameServiceInterface leaderboard){

         this._leaderboard = leaderboard;


And now you can just call/bind _leaderboard.login() or any other method of the GameServiceInterface anytime in your game.

LibGDX and RevMob integration

I figured I would do a small tutorial on this subject since I had to implement it recently on my current project.

I want to display Full Screen RevMob ad in my Android game in between two levels. Displaying banner ads is slightly different and won’t be covered here.

Setup and configure RevMob

  1. First, grab the RevMob SDK from their website, for this tutorial, I will pick Android as the target platform. (You can also check the configuration step from their website for the most up to date instructions)
  2. Copy the revmob-n.n.n.jar in your android project libs’s folder and add it to your build path (in Eclipse, right click on the jar -> Add to build path)
  3. Modify your project’s manifest, add the following permissions
    • <uses-permission android:name="android.permission.INTERNET"/>
    • <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
    • <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
    • <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> (This one is optional but recommended)
  4. Add the following activity to your manifest (supposing you want to use full screen ads in your application)
    • <activity android:name=”” android:configChanges=”keyboardHidden|orientation”> </activity>
  5. Also don’t forget to create your application in the RevMob console and grab your application ID

Configure LibGDX projects

Next you want to configure your LibGDX projects. Let’s suppose your game is multiplatform and you have an Android, Web, Desktop. You want to display RevMob ads only in your Android game and use another ads platform for Web/Desktop (since RevMob is mobile only) or maybe your desktop version won’t be displaying any ads anyway.

First let’s create an Interface in your main project to specify the actions correspond to the display of ads.

public interface AdsDisplayInterface{
   public void showFullScreenAds();
   public void openAdsLink();

This interface correspond to the different actions you might want to do in your game (for example show a full screen ads between two levels, or open the affiliate link when the “More Applications” button is clicked…)

Now you want to create a class implementing this Interface in the platforms where you want to display ads

In the Android project, we will create the following class

public class RevMobDisplay implements AdsDisplayInterface {
   private static final String REVMOB_APP_ID = &quot;copy your RevMob App ID here&quot;;
   private MainActivity activity;
   private RevMob revmob;

   public RevMobDisplay(MainActivity mainActivity){
      this.activity = mainActivity;
      revmob = RevMob.start(mainActivity, REVMOB_APP_ID);
   public void showFullScreenAds(){

   public void openAdsLink(){
      revmob.openAdLink(activity, listener);

Now, in the main Android class, create an instance of this class and pass it as an argument to the Game constructor:

public class MainActivity extends AndroidApplication {
   public void onCreate(Bundle savedInstanceState) {

      AndroidApplicationConfiguration cfg = new AndroidApplicationConfiguration();

      initialize(new Game(new RevMobDisplay(this)), cfg);

Eclipse should warn you that there is an error with this modified code because the Game constructor does not expect this argument.So we will create a new constructor that expects this argument in your main project’s Game class (this is the Class that implements ApplicationListener)

public class Game implements ApplicationListener {
   public AdsDisplayInterface _adsDisplay;

   public Game(AdsDisplayInterface adsDisplay){
      _adsDisplay = adsDisplay;

   public Game(){

      public void create() {

Displaying Ads

Now, whenever you want to display a fullscreen ad, you can simply do the following:

if (_adsDisplay!=null){

Remember we only created this class for the Android application, so if we tried to display ads from another platform, it would crash with a null pointer exception, so we check if it is null beforehand.

There you go, let me know if you have any questions in comments.

30 Second review of Cube Overlord on YouTube

Some time ago I contacted a YouTube reviewer for Cube Overlord and there is now a 30 seconds review available :)

While it’s quite short and doesn’t go into much detail about the different game modes, powerups … It presents the basis for this game quite clearly.

Since I haven’t managed to do any video/trailer for my game, it’s a good start if you wanna check it out!