如何调试从Android应用程序共享libarary [单独的项目]应用程序、项目、Android、libarary

2023-09-05 07:33:10 作者:哥斯拉

我开发一个Android应用程序,并通过密集的C ++ code项目, 首先,我把C ++源$ C ​​$ C项目,并使用了以下指南已经在Android应用程序本机调试的NDK能力。

I am developing an android application and using intensive c++ code in the project , First I put the c++ source code in the project and used the following guide to have the NDK capability of Native Debugging in the Android application .

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

但发展weaks后,我决定分开本土code在一个独立的项目,并使用输出,所以在Android应用程序。

but after weaks of development I decided to separate the Native code in a standalone project and use the output SO in the Android Application .

我的问题是我怎么可以调试SO库,它是在Android应用程序一个单独的项目的结果?

推荐答案

使用NKD-GDB这个(你的。所以就必须包含在您的应用程序的应用程序特定的安装,在正常位置的APK .so文件),它是NDK的一部分。见$ NDK /文档/ NDK-GDB.html

Use nkd-gdb for this (your .so will have to be included in the APK that you installed for your application, in the normal location for app-specific .so files) It is part of the NDK. See $NDK/docs/NDK-GDB.html

不过,要注意:NKD-GDB只会GDB和你的。所以在应用程序启动后一段时间。所以,你可能会错过一些断点。我知道有2种方式来解决这个问题,一个IDE插件之外的:

But, be warned: nkd-gdb will only attach GDB to your .so sometime after the application has started. So, you might miss some breakpoints. I know of 2 ways to solve that problem, outside of an IDE plugin:

将在最早的入口点你。所以一个无限循环,然后用GDB打出来的无限循环中,您已设置断点后 在下载待处理的更新NDK-gdb的,它修复了这个问题,从的https: //android-review.googlesource.com/#/c/48029/ (一人已报告有问题,我修复,所以它没有被批准用于AOSP尚未...但我从来没有重现他们的问题。请让我知道如果你使用它,以及它是否适合你或没有。) Place an infinite loop at the earliest entry-point of your .so, then use GDB to break out of that infinite loop, after you have set your breakpoints Download my pending update to ndk-gdb, which fixes this problem, from https://android-review.googlesource.com/#/c/48029/ (One person has reported having problems with my fix, so it is not approved for AOSP yet... but I have never reproduced their problem. Please let me know if you use it, and whether it works for you or not.)