Debugging an Android NDK application with NDK GDB

Android NDK introduces a shell script named ndk-gdb to help one to launch a debugging session to debug the native code.

Getting ready

The project must meet the following requirements in order to debug it with ndk-gdb:

  • The application is built with the ndk-build command.
  • AndroidManifest.xml has the android:debuggable attribute of the <application> element set to true. This indicates that the application is debuggable even when it is running on a device in the user mode.
  • The application should be running on Android 2.2 or higher.

Please read the Building Android NDK Application at Eclipse recipe before going through this one.

How to do it...

The following steps create a sample Android project and debug ...

Get Android Native Development Kit Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.