3. Prerequisite
Build Debuggable JNI Lib
● Download android-ndk-r9
● In AndroidManifest.xml
● android:debuggable=true
● In Application.mk, APP_OPTIM := debug.
● Without this variable is also fine. Just don't let it be
"release".
● Build Code: ndk-build NDK_DEBUG=1
4. Prerequisite
Cygwin Environment
● Download and install cygwin
● Remember to install make(2.7 or higher)
● Install JDK and set up env variables, PATH and
CLASSPATH
● Without JDK is also fine, but have to run ndk-gdb
with "--nowait".
● Set up path to android-sdk and ndk in PATH
env variables.
● For unix-like env, just set up these relative
paths.
5. Debug with ndk-gdb
Steps
● First, run your debuggle app directly or via
eclipse.
● Open cygwin and go to where your project
resides.
● Execute ndk-gdb
● With --nowait specified if no JDK installed.
● Set up some break points and start debugging!
6. Debug with ndk-gdb
Basic gdb commands
● break (br or b): Setup break points
● info br: Show all break points
● bt: Display call stack
● list: Show next ten lines of code
● print (p): Print the content of variable
● continue (c): Continue the process.
● step (s): Step to next line
7. Set up eclipse gdb
● CDT plugin is required!
● Create C/C++ debug configuration.
11. Set up eclipse gdb
Modify scripts
● ndk-gdb
● Make a copy and rename it as ndk-gdb-eclipse
● Edit the new file and comment out the last line
– #$GDBCLIENT -x `native_path $GDBSETUP`
● gdb.setup
● The file located at objlocalarmeabigdb.setup .
● Make a copy named gdb2.setup
● Delete the last line
– target remote :5039
12. Debug JNI in eclipse
● First, run your debuggle app directly or via
eclipse
● Open cygwin and go to where your project
resides.
● Execute ndk-gdb-eclipse
● With --nowait specified if no JDK installed.
● Wait until the command finish
● Go back to eclipse and execute the debug
configuration just created!