I’m Back (and SoundPool on Android is broken)

I’m back. Been to Disneyland with my better half, we are engaged 😀 It was a blast.


Coming back, i now have the awesome task of figuring out the state of libgdx and any issues that may have arisen during my absense. The build server is still humming along. The issue tracker hasn’t grown immensely. I’ll do a forum run tonight and catch up with Nex/Xoppa/Nate/etc.

The recent Android 4.3 release broke looping for sound effects. The problem is located in SoundPool, and Android class we use to playback sound effects. Android 4.3 introduced a bug that breaks looping of sound effects.

You can star the bug on the Android issue tracker. Refrain from posting “me too” comments, anyone subscribed will receive your useless message.

There’s currently no work around, using MediaPlayer is to heavyweight and hence not an option. This doesn’t affect libgdx only, other frameworks and engines have the same problem now.

libgdx and Android x86

For quite some time now, folks have asked if we could provide Android x86 builds of our native libraries. Today we granted that wish. The nightlies now come packaged with x86 Android binaries of our native libraries. This includes libgdx.so, as well as the natives of gdx-bullet, gdx-freetype and gdx-image. gdx-audio is currently only available for ARM, due to it using ARM assembly to speed up decoding.

To use the x86 natives, simply copy the x86/ folder from the nightlies to your Android project’s libs/ folder (next to the armeabi and armeabi-v7a folder). The setup-ui will not add those libraries for you automatically. I opted to do it this way for the time being as x86 Android devices are super rare, and you’d just blow up the size of your APK unnecessarily.

I also removed libandroidgl20.so. That contained our custom Android OpenGL ES 2.0 bindings. They are now directly compiled into the libgdx.so file.


Google I/O 2013 from a game devs perspective

Some pretty big things have dropped at this year’s Google I/O. Here’s a rundown of what i think is relevant to game devs.

Android Studio

The Android development tools team released a new IDE called Android Studio. Android Studio is based on IntelliJ IDEA by JetBrains. While you could previously develop Android Applications with IntelliJ IDEA, Android Studio adds a metric ton of features that make pure Android development a joy (once the IDE is stable).

Among those features are integration of the new Gradle-based Android build system (which still lacks support for native libraries), super awesome Linting (checks your source code for various types of errors the standard Java compiler doesn’t catch, with the help of annotations on most of the Android APIs), Android specific editor features (replaces resources like R.stuff with the actual string representation, shows resource images in the editor margin), and a nice layout editor with drag & drop functionality, as well as previews for different resolutions etc.

If you are interested, you should totally watch the talk “What’s New in Android Development Tools”:

Note that Android Studio is at version 0.1, and hiccups are to be expected. Regardless, the features demonstrated at I/O are really neat, and i can see how this can make developing Android apps a lot better experience.

However, there are also down-sides to this in my opinion. First of all, it is unclear how they plan on supporting both Eclipse and Android Studio, and how the IntelliJ IDEA Android plugin plays into all of this (iirc, that was managed by IDEA/the community so far). I’d speculate that the tools team doesn’t have the man power to maintain all of these things ad infinitum. E.g. will the new Gradle build system get some love in Eclipse as well? My guestimate is that Eclipse development will eventually be handed over to the community, hopefully after the Gradle build system has been added to ADT.

Another downside is that Android Studio can not be used for anything other than Android projects, e.g. Java projects. For libgdx, that’s a bit of a bummer, as our cross-platform project structure does not consist of an Android-only project for obvious reasons. I haven’t looked to hard yet, but there doesn’t appear to be a solution for that. On the other hand, most libgdx apps development wouldn’t benefit much from the new features in Android Studio anyways (apart from the Gradle build). A libgdx app normally doesn’t call into Android APIs itself, and also doesn’t have to manage UI layouts or resources the Android way. If you are still interested in using Anroid Studio with your libgdx app, check out this thread.

Hopefully the IntelliJ IDEA community edition version of the Android plugin will get up to speed with what Android Studio offers. Likewise, i hope that Eclipse isn’t killed entirely as an Android development environment.

Google Play Game Services

As anticipated by many outlets on the web before I/O, Google presented it’s new Game Center like service called Google Play Game Services (quite a mouth full). It allows you to “easily” add achievements, leaderboards, and cloud storage of game state across multiple devices. Users login with their G+ account (sneaky :)), and can then share their achievements and scores with friends within their circles. On top of this base social gaming functionality, Google Play Game Services (calling it GPGS from now on), supports setting up peer to peer multiplayer games on Android devices, including nice things like lobby rooms and so on.

The real kicker is that all these services work not only on Android, but also on the Web and on iOS, except for multiplayer which is only supported on Android.

One of my biggest issue with existing social gaming platforms is that you can’t just fetch the data and display it however you want. The GPGS team was smart enough to make it a design principle that you as a developer have full control over how you want to consume the service. Most folks will be fine with using the standard UI that the GPGS SDK comes with. If you want to go full customization, you can, which is awesome!

Naturally, there where quite a few talks on these new services. Here’s a list of what i found the most informative:

“Practical Android Games Development”, gives you a great introductionary overview of how to setup GPGS for leaderboards, achievements etc. in your dashboard, what the APIs offer you and so on.

“Mobile Multiplayer Made Manageable”, gives you an overview of how to use the multiplayer services on Android.

“Advanced Game Development Tools”, gives a bit more in depth info on how to resolve cloud save state conflicts, integration with 3rd party engines and so on. Really liked this one.

You can integrate the GPGS today in your libgdx app. Nex already did so on a basic level for his Mathematiles game (not published yet). The gist of it goes like this:

  1. Setup your app in the dashboard, including achievements, leaderboards etc. Follow the docs on the GPGS site.
  2. Install the GPGS SDK and add it to your Android project
  3. Check out the sample projects. The BaseGameUtils project has a GameHelper class that wraps the GPGS. You can directly take that file and drop it into your Android project. It’s a nice “little” wrapper around the service APIs that should make your live easier.
  4. To be able to still iterate on the desktop, follow this guide on how to integrate platform specific APIs, like the GPGS API. Also make sure to follow the thread linked to in the beginning.
  5. Use your wrapper to integrate the GPGS services 🙂

This is of course a very coarse description of what to do. We’ll follow up with a proper tutorial on the Wiki eventually, ala Swarm.

I’m really quite excited about these new services, but am also kinda worried what this means for our friends over at Swarm Connect. Haven’t heard from them yet. We’ll see how that turns out.

I also wonder how the G+ dependency will work out. On Android it’s a no-brainer, sign-up/login is stupidly simple. I’m not sure how well that will work on the web and iOS for the non G+ audience.

Finally, i’m really looking forward how Apple will react to this. 3rd party social gaming platforms ala OpenFeint etc. have been tolerated even after the introduction of Game Center. This move by Google might just tick them off a bit.

Overall, the cross-platformness in combination with the contact managment of G+ looks to be a great addition to the social gaming ecosystem.

Staging, Alpha and Beta Testing on the Play Store

Play Store publishing has been extended with new features. You can now do alpha/beta testing with a select group of people. All of this is accessible in the developer console. Pascal of OrangePixel fame already tried out this feature. It’s extremely smooth and helpful.

Other interesting stuff

One talk discussed how to do gameplay recordings on Android, in Unity. Big take away is that you can use the VP8 encoder in Android now 🙂

Chet Hase and Romain Guy gave their anual “how we make rendering on Android faster” talk. Not a lot of new things, but still super entertaining to watch.