Fork me on GitHub

Things I've learnt with Android development

I've learnt a lot when it comes to Android development, here is a summary:

Using the Android NDK is hard

Seriously. If I wasn't porting an existing game which was already coded in c/c++, I wouldn't bother. Getting compiles working, getting the Java shim working, it's all a lot of work.

You don't only need to get your own code to work - all of the libraries you use and all of their dependencies need to be compiled for Android. To make things harder, not everything compiled out of the box. I needed to code up patches to get things working properly.

Google have repos for common libraries

There are heaps of libraries in the Android source repos (platform/external/*) which are basically upstream libraries patched to work properly on Android, and with a ready-to-go file.

After spening ages trying to mash freetype into Android, I discovered they've already done it.

Word of warning though. It appears people (Google employees?) do lots of work on these libs and then only push when a new version of Android comes out. When 4.4 KitKat came out, the freetype repo got a few extra commits, but there was lots of changes in them and they broke my build. I ended up forcing 8afe960 which was the last one which worked properly.

Spend time on good logging

One of the most useful things is a decent logging macro. There is one as a part of Android, but if you're doing cross-platform dev you'll need to wrap that with something. I ended up using a macro which wraps either the Android logger or good-ol printf.

The Android dev tools are really not too bad once you get to know them; adb logcat was a lifesaver.


After days of bashing my head against the wall trying to figure out why I was only getting a black screen, I discovered various errors in my shaders.

Only once I had added lots of logging to my shader comple and link stages did I discover that the OpenGL shading language uses a different syntax to the OpenGL ES shading language. They are similar, but the ES SL uses the keywords from GLSL 1.0, even though it has some of the features of GLSL 1.3 and similar.

One of the coolest tools I found was Shdr Editor, an online shader validator and experimental area. It uses WebGL, which is generally OpenGL ES 2.0

Issues with SDL_CreateWindow in SDL 2.0

It's not Android releated - this was just a personal mistake. I thought that if I passed SDL_CreateWindow the SDL_FULLSCREEN flag and a width and height of 0, it would assume the screen size. It doesn't, and it doesn't throw an error or assert either. It just doesn't work.

What's next?

Well I've still got more Android work to do, so there will probably be more notes going forward. I still need to implement controls so I'll probably learn more about multi-touch and the accelerometer going forward.

Post a comment

Leave the following field blank, it is an anti-spam field.

Email address: