在 Android 库中调试本机代码

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12638849/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 11:16:50  来源:igfitidea点击:

Debug native code in Android Library

androiddebuggingandroid-ndkandroid-library

提问by spacifici

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 中调试本机库?有人对此有所暗示吗?

采纳答案by Jay

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:

通过将未剥离的共享库/库的目录添加到调试配置对话框中的调试器,我能够在 Eclipse 上的 android 库中设置断点和调试本机代码:

  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.
  1. 转到“运行”菜单->“调试配置”
  2. 在左窗格中的“Android Native Application”下,选择您的应用程序
  3. 在“调试器”选项卡下,单击“共享库”部分中的“添加...”。
  4. 浏览到您的 android 库项目目录并添加其子目录 obj/local/armeabi。
  5. 应用和调试。

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

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

Peace

和平

回答by RDX

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

  1. 更新您的构建配置以包含“NDK_DEBUG = 1”。右键单击项目 -> 属性 -> C/C++ Build:

  2. 在 C 代码中设置断点。

  3. 右键单击您的项目,选择 Debug As -> Android Native Application

For more details follow:

更多详情请关注:

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

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