Note! If you're having problems compiling one of the example apps with "Conversion to Dalvik format failed with error 1" see below.
Here's an Android Eclipse library project for AndModPlug (Java wrapper classes + libmodplug).
At this stage, it's probably best to use the jar and compiled libmodplug.so here. See below for the zip archive. If you use the code, a shout-out via the tweet button above and/or mention in your blog or game credits would be much appreciated!
Let's get started
This is libmodplug (version 0.8.8.4 from sourceforge) built with revision 8 of the Android NDK. You'll find AndModLib (JNI stub code + the PlayerThread class) built as a library you can include in your own project, plus two demo apps that use the library to play a few songs. Unlike the earlier version of libmodplug in Android, this version should accept mod, xm files larger than 60K bytes. However, very large mod files may or may not work.
Why should you care about tracker music as a developer?
Because it can reduce the size of your soundtrack by a factor of 10. See the Soundtracks page for an example of this - an Android apk that uses libmodplug to play the full soundtracks of my games Voyage to Farland and RGBbot! (44 songs in 1.2MB)
1) download and unzip the archive
2) in Eclipse choose File->Import->Existing Projects into Workspace and select the directory where you unzipped the archive - it should have the three projects in it: AndModPlugLib, AndModPlayerApp & AndModResourcePlayerApp.
3) try out AndModPlayerApp or AndModResourcePlayerApp on your phone or emulator (you might have to clean the projects first - Eclipse is funny about that...) They don't run all that smoothly on the emulator, but you should at least be able to hear it playing music.
4) then you can integrate AndModPlug into your own game or app following the two examples (AndModPlayerApp & AndModResourcePlayerApp)
If you want to modify or rebuild AndModPlug, you'll need the Android NDK. The AndModPlug project in the archive has a custom Builder to compile libmodplug together with jni_stubs.cpp. You may want to go to the sourceforge link above to get the latest libmodplug source itself. My main contributions here are the Android.mk makefile and jni_stubs.cpp, the JNI stub code.
You may also have to modify the Native Builder if you're running Linux, etc.:
Note: If you get the error - "Conversion to Dalvik format failed with error 1" while trying to build an app with AndModPlug. Here's how to fix it! Involves removing legacy _src directories for imported libraries.
Stay tuned for better instructions and code improvements.
Thanks to Ryu for the post about native builder arguments here!
Want to say thanks?
If you find my work useful in your projects and would like to say thanks, you can click the button below to see how to donate (via PayPal or just by buying one of the very affordable games :)