Struggling with the Android SDK on FreeBSD

Friday April 02, 2010 by cl0secall

I started out by trying the "BSDroid" port of the SDK. After some toil, I was able to get projects to build, but wasn't able to get the debugger/emulator to work. I even tried using truss/ktrace to debug the debugger/emulator but was never able to isolate the problem.

Ultimately I decided to try the "freebroid" SDK port. The documentation was extremely simplistic, and I had to figure out how to use `git` in order to gain any traction. The "" script ended up needing to be modified (I added ":FreeBSD-host" to the end of the `git fetch` string, so that the "FreeBSD-host" branch would be created) so that the "" script would actually work. Initially I had been getting errors about "no branch" or something similar.

The next hurdle was learning that I needed the JDK 1.5 instead of 1.6, as BSDroid had abstracted all of that and/or rendered it otherwise unneccesary. Once I installed the 1.5 JDK and set JAVA_VERSION to 1.5, and JAVA_HOME and ANDROID_JAVA_HOME to "/usr/local/diablo-jdk1.5.0" I was up and running. At least until the next hurdle.

I next had to modify the "external/srec/tools/grxmlcompile/" file to include the same "ifndef \$HOST_OS, freebsd" clause around the "LOCAL_LDFLAGS += -ldl" line so that the linker wasn't searching for the nonexistent libdl library. At this point I decided that I've been playing with this for too long without documenting my progress. It's still building right now... or not. Great, something about SDL. I guess I'll be at this for some time.

Update: I forgot to mention that I also had to set LD_LIBRARY_PATH to "out/host/freebsd-x86/lib" so that I didn't get an error about a missing "". Now I'm struggling with the error "no rule to make target libSDL.a".

Update 2: I finally figured out the SDL problem. The android emulator uses a forked version of the SDL 1.2 library with functions that are (apparently) part of the SDL 1.3 specification, but using the SDL 1.2 nomenclature (specifically SDL_WM_GetPos and SDL_WM_SetPos). As these aren't in my system default library, and the freebroid project has set up the port not to build the android-supplied libSDL, I'll have to do the work myself.

Update 3: Turns out that the libSDL source that is available on is out of date. A newer (prebuilt binary) version of libSDL was added to the tree since then, and is incompatible with the older sources due to the addition of two new functions: SDL_WM_GetMonitorDPI and SDL_WM_GetMonitorRect. As such, I'll have to try to revert my local tree to the previous version and recompile. As I really don't know the tools that well this will take some time. The relevant commit message can be found here.

Update 4: I decided to check the git tree under external/qemu to see if the sources were ever committed, and maybe there just wasn't any record of this change. Sure enough, I found this and used the source code located at external/qemu/distrib/sdl-1.2.12 to build the modified SDL package. Also, I've put together a project page which has the distillation of this saga into a few instructions.