hello-gdbserver: A debuggable JNI example for Android


Before I get into the rest of the post, here is a link to a .zip of the Eclipse project files if you just want to skip ahead.

The Rest Of The Post

Native software development on Android using its JNI capabilities is incredibly frustrating without proper visibility into the causes of native code errors.

Here is an example project and some background info that shows how to get gdb and gdbserver working to catch those nasty bugs. Just extract the project files into the NDK’s sample directory and import the project into Eclipse.

Here were some of the search terms I tried unsuccessfully while trying find something like this:

using gdb on android
using ndk-gdb
debug jni android
hello world android native code
hello world android emulator
debugging using gdbserver android


  • A phone running Android 2.2 (Froyo) (might work on the emulator, but I didn’t focus on that)
  • The latest Android NDK (at least r4b)
  • Lots of Patience

The NDK-GDB.TXT readme file in the NDK has a good overview of the process of getting a debuggable Android application + JNI build set up, but I would have much preferred it if Google had simply included something like a hello-gdbserver test app in the provided samples. One simple app where you could induce a crash to see what would happen, like a tutorial for smarter bug-hunting. So, I made this one. Continue reading hello-gdbserver: A debuggable JNI example for Android