20

My workspace layout is:

.
├── ApplicationLibrary
│   ├── AndroidManifest.xml
│   ├── ...
│   ├── jni
│   ├── libs
│   ├── ...
│   └── src
└── Application
    ├── AndroidManifest.xml
    ├── ant.properties
    └── ...

How can I debug the native library in Eclipse? Has anyone some hint about this?

Blackbelt
  • 156,034
  • 29
  • 297
  • 305
spacifici
  • 2,186
  • 2
  • 16
  • 28

2 Answers2

16

I was able to set breakpoints and debug native code in an android library on eclipse by adding the directory of the unstripped shared library/libraries to the debugger in the debug configurations dialog:

  1. Go to "Run" menu-> "Debug Configurations"
  2. Under "Android Native Application" in the left pane, select your application
  3. Under the "Debugger" tab click "Add..." in the "Shared Libraries" section.
  4. Browse to your android library project directory and add its subdirectory obj/local/armeabi.
  5. Apply and debug.

That seemed to work for me. Hopefully, you'll have the same luck...

Peace

Jay
  • 271
  • 2
  • 6
  • One addition, it looks like you might also need to add the library project to the "source" tab in that dialog box... "Run"->"Debug Configurations...", select your application, "Source" tab, "Add...", "Project", select your library – Jay Jan 23 '13 at 15:49
  • Thanks Jay for this tip. It worked for me without having to add the library in the source tab. Why did you came to that conclusion? – znat Apr 04 '13 at 15:48
  • 4
    @Jay My Android application doesn't have any native code, but the Android Library project it references have native code in it. In this case how can I debug it? In Debug configurations under "Android Native Application", I cannot find my application there so what should I do? Thanks! – Bruce May 18 '14 at 12:25
  • Awesome i really happy now..Thank you alot – Naveen Kumar Kuppan Jun 10 '14 at 14:21
  • 3
    @Jay - I cant find Android Native Application in the left pane. Can you please tell me how can I add that into my Debug Configuration? Thank you – Ahmed Jul 30 '14 at 16:53
1

It is possible:

  1. Update your build config to include “NDK_DEBUG = 1”. Right click project -> properties -> C/C++ Build:

  2. Set a breakpoint in your C code.

  3. Right click on your project, select Debug As -> Android Native Application

For more details follow:

http://tools.android.com/recent/usingthendkplugin

Rohit
  • 6,941
  • 17
  • 58
  • 102
  • 2
    That's not the problem, I know how to debug a native code in the same application, the problem is: how to debug native code in an Android Library – spacifici Jan 12 '13 at 17:29