如何获得断点NDK本地code和调试本地code Android Studio中?

问题描述:

我使用NDK开发Android应用程序。我有两个项目。一个是它使用NDK并生成.so文件我的本地库。

I am developing android app using NDK. I have two projects. One is for my native library which uses NDK and generates .so file.

我使用的Andr​​oid Studio,但禁用自动构建和使用NDK,构建支持版本。我使用Windows 7。

I am using Android Studio but disabling auto build and enabled build using ndk-build. I am using Windows 7.

现在生成的.so文件后,我复制那些在其中也使用NDK的构建来编译在我打电话我的图书馆功能JNI功能我主要的应用程序项目。我希望我是干净的,直到这一点。如果没有,那么我会给要求更多的细节。

Now after generating .so file I copy those in my main application project which also uses ndk-build to compile JNI functions in which I am calling functions of my library. I hope I am clean till this point. If not then I will give more detail on request.

现在我正在使用Android的工作室我的设备应用程序,我可以把Java的code和调试中断点code,但我不能够调试JNI调用,也是本土code这我在单独的项目。我需要我的图书馆code内进行调试。那么,有没有办法做到这一点?

Now I am running my application in device using Android Studio and I can put break point in java code and debug that code but I am not able to debug JNI call and also native code which I have in separate project. I need to debug inside my library code. So is there any way to achieve this?

我已经看到VisualGDB但它支付。因此,让我知道,如果有任何替代充分填补我调试requirements.I已经搜索很多,但没有得到任何具体的解决方案。

I have seen VisualGDB but it is paid. So let me know if there is any alternative to full fill my debugging requirements.I have searched lot but did not get any concrete solution.

我可以看到Android Studio中的选项用于连接到Android的过程中,我可以看到我跑设备,但我不知道如何使用它,所以我可以通过本机库code(这是在单独的项目没有任何调试活动)。

I can see option in Android Studio for attaching to android process where I can see my running device but I am not sure how to use it so I can debug by native library code (which is in separate project without any activity).

让我知道,如果需要更详细

Let me know if more detail is required

在Android Studio中2.0 preVIEW的过程是一个有点不同(ANS更容易,我认为):

In Android Studio 2.0 preview the process is a bit different (ans easier I think):


  1. 安装LLDB:走入工具 - > Android-> SDK管理器,然后再在SDK工具选项卡,并确保选中LLDB(接近列表的末尾通常情况下)

  2. 选择/调试变种:在AS的左下角,点击生成变种,默认调试版本被称为调试

  3. :选择本机配置:运行按钮(绿色三角形)的左侧,默认本机配置被称为应用原生

  4. 设置断点

  5. 通过点击运行按钮右侧的小虫子启动您的应用程序在调试

  1. Install "LLDB": Go in Tools->Android->SDK Manager, then go in the "SDK Tools" tab and make sure to check "LLDB" (Near the end of the list usually)
  2. Select a/the "Debug" variant: In the lower left corner of AS, click on "Build Variants", the default debug variant is called "Debug"
  3. Select a native configuration: left side of the run button (The green triangle),The default native configuration is called "app-native"
  4. Set a breakpoint
  5. Launch your app in debug by clicking on the little bug on the right side of the run button.

如果它不工作,请检查您的本机配置有调试型混合选择:在播放按钮的右侧,点击小三角,选择编辑配置,选择你的应用原生的配置,走在调试选项卡,选择调试类型:混合型。

If it doesn't work, check that your native configuration has debug type "Hybrid" selected: On the right of the play button, click the little triangle, select "Edit Configurations", select your "app-native" configuration, go in the "Debugger" tab and select "Debug type: Hybrid".