调试Android库中的本机代码

时间:2023-01-18 23:39:59

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?

如何在Eclipse中调试本机库?有人知道吗?

2 个解决方案

#1


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:

通过在debug configurations对话框中向调试器添加未剥离的共享库/库的目录,我能够设置断点并调试eclipse上的android库中的本机代码:

  1. Go to "Run" menu-> "Debug Configurations"
  2. 转到“运行”菜单->“调试配置”
  3. Under "Android Native Application" in the left pane, select your application
  4. 在左边窗格的“Android本机应用程序”下,选择您的应用程序
  5. Under the "Debugger" tab click "Add..." in the "Shared Libraries" section.
  6. 在“调试器”选项卡下,单击“共享库”部分中的“Add…”。
  7. Browse to your android library project directory and add its subdirectory obj/local/armeabi.
  8. 浏览到您的android库项目目录,并添加它的子目录obj/local/armeabi。
  9. Apply and debug.
  10. 应用和调试。

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

这似乎对我有用。希望你也有同样的运气……

Peace

和平

#2


2  

It is possible:

它是可能的:

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

    更新构建配置以包含“NDK_DEBUG = 1”。右击项目->属性-> C/ c++构建:

  2. Set a breakpoint in your C code.

    在C代码中设置断点。

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

    右键单击项目,选择Debug As -> Android本机应用程序

For more details follow:

更多细节:

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

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

#1


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:

通过在debug configurations对话框中向调试器添加未剥离的共享库/库的目录,我能够设置断点并调试eclipse上的android库中的本机代码:

  1. Go to "Run" menu-> "Debug Configurations"
  2. 转到“运行”菜单->“调试配置”
  3. Under "Android Native Application" in the left pane, select your application
  4. 在左边窗格的“Android本机应用程序”下,选择您的应用程序
  5. Under the "Debugger" tab click "Add..." in the "Shared Libraries" section.
  6. 在“调试器”选项卡下,单击“共享库”部分中的“Add…”。
  7. Browse to your android library project directory and add its subdirectory obj/local/armeabi.
  8. 浏览到您的android库项目目录,并添加它的子目录obj/local/armeabi。
  9. Apply and debug.
  10. 应用和调试。

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

这似乎对我有用。希望你也有同样的运气……

Peace

和平

#2


2  

It is possible:

它是可能的:

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

    更新构建配置以包含“NDK_DEBUG = 1”。右击项目->属性-> C/ c++构建:

  2. Set a breakpoint in your C code.

    在C代码中设置断点。

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

    右键单击项目,选择Debug As -> Android本机应用程序

For more details follow:

更多细节:

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

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