Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Microsoft debugger with Xamarin Android

There's an option in the Android project settings in the Android Options section on the Packaging tab that lets you choose between the Xamarin debugger or the Microsoft debugger. The Xamarin debugger works, but not as good as the Microsoft one might. Unfortunately I get an error message when trying to use the Microsoft debugger and deploy on one of the Visual Studio Android Emulators.

Unable to start debugging. Non-debuggable application installed on the target device. Required file '/data/data/My.Application/lib/gdbserver' could not be found on the device. Please install a debuggable version.

Is there any way to get the Microsoft debugger to work?

like image 760
Sorskoot Avatar asked Aug 18 '15 10:08

Sorskoot


1 Answers

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.

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.

To get gdbserver into the app package, you either have to reference a native code library from your managed app, or include it (with build action set to AndroidNativeLibrary). I found you can also add a link to gdbserver (again, with build action set to AndroidNativeLibrary) from a project and make use of path sniffing to select the gdbserver from the matching ABI. Snippet of project file:

  <ItemGroup>
    <AndroidNativeLibrary Include="$(ANDROID_NDK_ROOT)\prebuilt\android-arm\gdbserver\gdbserver">
      <Link>lib\armeabi-v7a\gdbserver</Link>
    </AndroidNativeLibrary>
  </ItemGroup>

Also please see my answer to a similar question.

like image 139
Richard Walters Avatar answered Sep 25 '22 07:09

Richard Walters