而在Visual Studio 2015年调试Android原生库断点不工作 [英] Breakpoints don't work while debugging native Android library in Visual Studio 2015

查看:1252
本文介绍了而在Visual Studio 2015年调试Android原生库断点不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在全新安装的Visual Studio 2015年我创建了一个Android应用程序和Android本机库。从本机库的功能,​​在应用程序code被引用过的DllImport指令。

On a fresh installation of Visual Studio 2015 I created an Android application and Android native library. Functions from native library are referenced in the app code through DllImport directives.

当我选择Xamarin调试器为主要的应用程序,并开始调试,我能够停止在C#code断点,但调试器不会踏入本地函数调用。

When I select "Xamarin debugger" for main app and start debugging, I am able to stop on breakpoints in C# code, but debugger doesn't step into native function calls.

当我选择Microsoft调试器断点不会在所有的工作。 在调试会话中的所有断点被标记为禁用,当我指出他们出现以下消息:

When I select "Microsoft debugger" breakpoints don't work at all. During debugging session all breakpoints are marked as disabled and when I point to them the following message occurs:

断点将目前尚未受到打击。含有该断点模块尚未加载。

什么我需要做的VS2015调试原生的Andr​​oid库?

What do I need to do to debug native Android libraries in VS2015?

推荐答案

我有同样的问题,我想我已经想通了。

I had the same problem and I think I've figured it out.

在Xamarin调试器只能调试管理(如C#)code。断点只与Xamarin调试工作,如果被调试的项目是一个管理项目。他们不工作,如果该项目是一个原生应用程序或本机库。

The Xamarin debugger can only debug managed (i.e. C#) code. Breakpoints only work with the Xamarin debugger if the project being debugged is a managed project. They don't work if the project is a native app or native library.

微软调试器只能调试本地(即C / C ++)code。断点只与Microsoft调试工作,如果被调试的项目是本机应用程序或本地库,或者如果它被连接到一个已经运行Android过程

The Microsoft debugger can only debug native (i.e. C/C++) code. Breakpoints only work with the Microsoft debugger if the project being debugged is a native app or native library, or if it is attached to an already-running Android process.

我已经能够同时使用调试器来调试混合(托管+原生)的应用程序,请按照以下步骤:

I've been able to use both debuggers simultaneously to debug a hybrid (managed+native) app, by following this procedure:

  • 在属性中管理应用程序,选择Xamarin调试程序:
  • 在属性的本机库项目,调试下,确保调试目标和包装将推出匹配选择的托管应用程序的目标和APK。这将确保这两个调试器被定向到同一个Android应用程序,并且还可以让你直接与微软的调试器启动应用程序(通过选择本机库为目标,以调试),如果您只想调试本地部分。您可能需要浏览APK,并为目标,您可能需要在目标名称,类型,如果它没有出现在下拉(目标名称是字符串亚行设备显示器)。
  • 选择调试的管理应用程序,并确保目标架构和设备都在调试工具栏正确。例如,如果我想在我的Nexus 4,它采用ARM架构进行调试,我要确保ARM被选择为目标,而不是任何CPU,我的Nexus 4套为我的目标:
  • 在开始调试。在这一点上,Xamarin调试器是活动的,在C#code断点应该是工作。
  • 当管理应用程序仍在运行或正在调试,对本地库项目右键单击并选择Debug>附加到Android的过程。如果一切顺利的话,微软的调试程序将启动并连接到应用程序,以及(除了在本机端,可以这么说)。
  • In the properties for the managed app, select "Xamarin" for debugger:
  • In the properties for the native library project, under Debugging, make sure Debug Target and Package to Launch match the target and APK selected for the managed app. This will make sure both debuggers are directed to the same Android app, and also lets you launch the app directly with the Microsoft debugger (by selecting the native library as the target to debug) if you only want to debug the native part. You will probably need to browse for the APK, and for the target you may need to type in the target name if it doesn't appear in the dropdown (target names are the strings that "adb devices" displays).
  • Select the managed app for debugging, and make sure the target architecture and device are correct in the debug toolbar. For example, if I want to debug on my Nexus 4, which uses ARM architecture, I make sure ARM is selected for target, not "Any CPU", and my Nexus 4 set as my target:
  • Start debugging. At this point, the Xamarin debugger is active and breakpoints in C# code should be working.
  • While the managed app is still running or being debugged, right-click on the native library project and select Debug > Attach to Android process. If all goes well, the Microsoft debugger will start and attach to the app as well (except on the "native side", so to speak).

我做了一个简短的视频来证明这一点:使用Visual Studio 2015年 Android的调试托管和本机code

I made a short video to demonstrate this: Android debugging managed and native code using Visual Studio 2015

这篇关于而在Visual Studio 2015年调试Android原生库断点不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆