libGDX 1.6.1 released – Build System Change!

libGDX 1.6.1

This release contains a major change to the build system. I had to change the way the iOS project handles native libraries. Up until today, the ios/build.gradle file had a two tasks, copyNatives, and updateRoboVMXML. When you import your project into an IDE or build it via the CLI, these tasks will walk through all dependencies, extract the static libraries and rewrite your robovm.xml file. That’s not really nice.

This release fixes this long standing issue. iOS native libraries, e.g. for gdx code, freetype, bullet or box2d, are now packaged using RoboVMs Jar layout for native libs. The static libraries are stored inside a jar, in the directory META-INF/robovm/ios/libs. Additionally, a small robovm.xml file is stored in META-INF/robovm/ios/robovm.xml. This file specifies the native libraries in the libs directory that RoboVM should link.

If you update an existing project to libGDX 1.6.1, you need to make a few changes to the build.gradle and ios/build.gradle files of your project!

In the root build.gradle file, you will see something like this for the iOS project:

project(":ios") {
    apply plugin: 'java'
    apply plugin: 'robovm'

    configurations { natives }

    dependencies {
        compile "org.robovm:robovm-rt:${roboVMVersion}"
        compile "org.robovm:robovm-cocoatouch:${roboVMVersion}"
        compile project(":core")
        compile "com.badlogicgames.gdx:gdx-backend-robovm:$gdxVersion"
        natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-ios"

You need to change the natives config name to compile, just like what we use for the normal Java dependencies.

In the ios/build.gradle file, can remove the copyNatives and updateRoboVMXML tasks and any other line that references those tasks. You should end up with something like this (modulo your main class name!): = [ "src/" ]

sourceCompatibility = '1.7'
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'

ext {
	mainClassName = ""

launchIPhoneSimulator.dependsOn build
launchIPadSimulator.dependsOn build
launchIOSDevice.dependsOn build
createIPA.dependsOn build

eclipse.project {
    name = appName + "-ios"
    natures 'org.robovm.eclipse.RoboVMNature'

After this changes, simply set the gdxVersion in your root build.gradle to “1.6.1” and you are done.

Here are the full CHANGES for this release:

- Added optional hostname argument to Net.newServerSocket method to allow specific ip bindings for server applications made with gdx.
- Changed the way iOS native libs are handled. Removed updateRoboVMXML and copyNatives task from ios/build.gradle. Instead natives are now packaged in jars, within the META-INF/robovm/ios folder. Additionally, a robovm.xml file is stored there that gets merged with the project's robovm.xml file by RoboVM.


In other news, if you are interested in libGDX plus iOS you should cast your vote for RoboPods. RoboPods are bindings to 3rd party libraries like Admob, Google Play Game Services and so on that we at RoboVM will officially support going forward. See this blog post, including the poll.

Happy Coding!

libGDX 1.5.2 released (updated)

edit: well, i’m a bit of a terrible programmer person and botched the update of LWJGL on Mac OS X. Just released libGDX 1.5.2 for that reason. The below still applies :)


time for a new release. Here’s what changed:

- Fixed issue #2433 with color markup and alpha animation. 
- Fixed natives loading for LWJGL on Mac OS X
- Gradle updated to 2.2
- Android Gradle tooling updated to 1.0.0
- API Change: Switched from Timer to AnimationScheduler for driving main loop on GWT. Removed fps field from GwtApplicationConfiguration to instead let the browser choose the most optimal rate.
- API Change: Added pause and resume handling on GWT backend. When the browser supports the page visibility api, pause and resume will be called when the tab or window loses and gains visibility.
- API Change: Added concept of target actor, separate from the actor the action is added to. This allows an action to be added to one actor but affect another. This is useful to create a sequence of actions that affect many different actors. Previously this would require adding actions to each actor and using delays to get them to play in the correct order.
- Added 64-bit support for iOS sim and device
- Deprecated Node#children and Node#parent, added inheritTransform flag and methods to add/get/remove children
- API Change: By default keyframes are no longer copied from Model to ModelInstance but shared instead, can be changed using the `ModelInstance.defaultShareKeyframes` flag or `shareKeyframes` constructor argument.
- JSON minimal format now makes commas optional: newline can be used in place of any comma.
- JSON minimal format is now more lenient with unquoted strings: spaces and more are allowed.
- API Change: Added support for KTX/ZKTX file format,
- Update stb_image from v1.33 to v1.48, see
- Bullet Wrapper: added Gimpact, see
- API Addition: Added MeshPartBuilder#addMesh(...), can be used to more easily combine meshes/models
- Update to LWJGL 2.9.2, fixes fullscreen mode on "retina" displays
- Fixes to RoboVM backend which would crash if accelerometer is used.

Starting with this release we’ll also relax our versioning a little bit. We will not increase the minor version in case of minimal API changes as above.

Let us know if you run into any issues. See this wiki article on how to update your libGDX project to the latest version. The current libGDX version is “1.5.2”, the current nightly version is “1.5.3-SNAPSHOT”, OR you can just check our versions page which details all the versions of dependencies as well.

Let’s write a Chip8 emulator in Kotlin [Part 2: The first refactoring]


This series is a means for me to learn Kotlin. As such i might misuse some features of Kotlin, not follow best practices or simply to silly things. Please always check the comment section for feedback from more knowledgable people. I’ll also have follow up articles where i refactor the code to be more idiomatic. So, make sure to check back.


Part of learning a new language is to get to know the idioms. Thanks to feedback on the last articles, i have a pretty good idea how to reorganize the code to make it more maintainable and concise. Let’s get going.

Moving things around

In the previous article we created a few top-level methods, loadRom, decode, and disassemble. I put them in different files. Let’s clean that up. We want a single file that contains the top-level methods that make up the functionality of the emulator. (Chip8.kt).

package chip8;


fun loadRom(file: String): VmState {

fun decode(decoder: Decoder, address:Int, msb: Byte, lsb: Byte) {

fun disassemble(vmState: VmState): String {

That cleans up the files Disassembler.kt, main.kt. I think i’ll make it a habit to put top-level functions of a package into a file named after the package itself.

Extension properties instead of extension methods

We added a few extension methods to Int and Byte in the previous article. Ioannis Tsakpinis of LWJGL fame and avid Kotlin user pointed out a better way to handle these extensions. We’ll make them extension properties instead of extension methods (Extensions.kt):

val Int.hex: String get() = Integer.toHexString(this)
val Byte.hex: String get() = Integer.toHexString(this.toInt())
val Byte.hi: Int get() = (this.toInt() and 0xf0) shr 4
val Byte.lo: Int get() = this.toInt() and 0xf

I renamed the properties to shower names and fixed up any code relying on the old extension methods accordingly. This makes our decode function a lot more concise, e.g.

0x5 -> decoder.jeqr(msb.low(), lsb.high())

turns into

0x5 -> decoder.jeqr(msb.lo, lsb.hi)

It also cleans up our Disassembler, which is our next refactoring victim.

Shorter single line methods

Disassembler is composed of single line methods for the most part. We can omit all the curly braces and new lines, turning

override fun call(address: Int) {
    builder.line("call 0x${address.toHex()}")


    override fun call(address: Int) = builder.line("call 0x${address.hex}")

As per the definition of Decoder implemented by Disassembler, all of these methods need to return Unit. For Disassembler#before and Disassembler#unknown we can’t just apply the single line style. Remember, the return type of a single line style function is the type of the expression of that single line. In case of these two methods, we call StringBuilder#append, which returns the StringBuilder. That is obviously not of type Unit.

We can apply a trick pointed out by Andrey Breslav of Kotlin fame: create an Extension method called unit that returns, you guessed it, Unit. Let’s modify Disassembler.kt:

class Disassembler(): Decoder {
    val builder = StringBuilder()
    fun Any?.unit() {}
    override fun before(opCode: Int, address: Int) = builder.append("addr: 0x${address.hex}, op: 0x${opCode.hex}, ").unit()
    override fun unknown(opCode: Int, address: Int) = builder.append("Unknown opcode addr: 0x${address.hex}, op: 0x${opCode.hex}").unit()
    // as before...

Note the fun Any?.unit() {} extension method. It’s attached to any object (!= null) within the scope of Disassembler (i think). We can then rewrite the before and unknown methods to single line style, calling unit() to make the expression’s type Unit in accordance to our Decoder trait.

You can see the entire refactoring diff on Github.

Up Next

Next time we are going to write our first iteration of a simple interpreter.


Let’s write a Chip8 emulator in Kotlin [Part 0: Motivation & Setup]
Let’s write a Chip8 emulator in Kotlin [Part 1: A simple Disassembler]

Following Along

  1. Install the required tools (JDK, IDEA, IDEA Kotlin plugin, Git)
  2. Clone the repo: git clone
  3. Checkout the tag for the article you want to work with: git checkout part2
  4. Import the project into IDEA (Open Project, select build.gradle file, select "Use customizable gradle wrapper"