Has anyone tried this action? Share your experience. I am trying via cygwin + ndk-gdb. OS - Windows.

Debugging occurs on the emulator.

  • Are we talking about a live device or debugging in an emulator? - cy6erGn0m

4 answers 4

If debugging from under eclipse + gdb, then:

  1. put a breakpoint in java in place before calling a binary function;
  2. run the code for execution and wait for the breakpoint to be triggered;
  3. go to the project folder from the terminal and execute ndk-gdb;
  4. put a breakpoint at the right place in the c-code;
  5. resume the execution of the program in eclipse and wait for the c-code to trigger the break;
  6. Further as usual in gdb.

This is tested on ubuntu. There may be differences under cygwin.

    I debugged applications remotely on a piece of iron, but not android, but simply Linux. This works well, only you need to have gdb compiled for the machine on which the application is running (for arm in this case). You can even pick up an IDE, if it is smart enough.

    • And what do you need for debugging? Where to read? - Nicolas Chabanovsky

    3 things are important:

    • ndk-build NDK_DEBUG = 1 (generates a debugging code);
    • On the device, / data / data / <package name> / lib must be gdbserver (gradle: jniDebuggable, eclipse and ant have no problems with this);
    • Patience. If something does not work, open ndk-gdb and erase it, specify the necessary parameters, do not link.
    • This answer is already irrelevant, in Android Studio everything works out of the box. - Jake Finn

    All native code is first debugged in Visual Studio. If you need data from the device (for example, gps), wrote a small code that transfers data to a computer. In theory, debugging with ++ code on a device / emulator is not needed in principle, it is much slower and more complicated.