28 June 2013
Comments: 2

MoPub’s Unity plugin

I’m almost at the point now on Galaxy Explorer where I need to start installing 3rd party libraries for ads, in-app purchases, etc.

I thought I’d start with MoPub, a company which provides what looks like a pretty decent method of supporting multiple ad networks, from one Dashboard, for IOS and Android.

MoPub has some handy docs for getting it all setup an running, but as usual, they leave key things that an Eclipse expert would know, such as how to get MoPub to compile without errors.

The instructions are fairly straightforward, but leave out a few important things:

  1. Use the full Android SDK that includes Eclipse to build the plugin. It’s easier than setting up vanilla Eclipse from scratch.
  2. You need to have Android SDK version 4 (Android 1.6) and version 16 (Android 4.1.2) installed – Mopub requires it, even if your app uses a different version of Android. If you don’t have these installed, you’ll see an error like Unable to resolve “target ‘android-4′”.
  3. The resulting jar file is called “mopub-sdk.jar”, not “MoPubPlugin.jar” as stated in the docs. You need to rename the file when it is copied to the Unity project.

Now that you’ve got Eclipse working, time to fix the MoPub compilation problems because the current version of the Unity plugin is broken, reporting the following error when compiled in Eclipse:

The type MoPubUnityPlugin must implement the inherited abstract method MoPubInterstitial.InterstitialAdListener.onInterstitialClicked(MoPubInterstitial) MoPubUnityPlugin.java /mopub-sdk/src/main/java/com/mopub/mobileads line 17

There’s been changes made to MoPub, but they’ve neglected to update the Unity plugin, so it will not compile without adding the following code to the MoPubUnityPlugin.java file, before the final closing brace “}”:

I’ve reported this on the Git page, hopefully someone who knows how this is supposed to work will fix it.

And finally, one more problem for the road. Unity seems to be incompatible with the latest Android SDK builds. Yay!

I updated to the latest SDK, only to have any Android Unity build fail with the following error:

Error building Player: Exception: android (invokation failed)
ERROR: unknown error

“unknown error” is very helpful.

I’m not the only one seeing this, and for me the solution was to revert to the old SDK I was using. I do daily backups, and once I’d put back yesterday’s SDK, Unity started working again.

I can report that after jumping through all these hoops, I was finally able to get the demo provided with the MoPub plugin to compile and run on Android, serving up test banner ads.

So much for my weekend release plan.

A quick Exoplanet Explorer update

I should mention that I had a slight issue with the data update I released a couple of days ago.

While the data did update, the index file magically changed it’s name from “systems.xml” to “xml.systems” during the upload to production (due to keyboard shortcut differences between MacOS and the virtualised updater running on Linux).

I didn’t notice this at the time, but it’s fixed now, and starting Exoplanet Explorer will now update the data. Honest.

  • AsdfAs

    Thank you! I was scratching my head for a while on this one.

    • http://apps.burlock.org Neil B

      I ended up removing MoPub from my projects. There’s just too many issues with the Android version.