0

I'm using Visual Studio 2017 to build and deploy a NativeActivity to my Android device. It builds and deploys with no issues, but I cannot set breakpoints.

Before running, I can add a breakpoint to a line (the first line of android_main() for example) and the little red circle shows up on the left of that line in the IDE as you'd expect.

But after installing and running the app, the breakpoint doesn't trigger because the red circle has turned white - it's saying there are no debug symbols.

I've verified I'm building the Debug version and have verified the APK file is bigger and has the debug symbols by using Android Studio.

At this point it appears to me that Visual Studio itself is confused and somehow doesn't recognize the debug symbols.

I've added "-g" to the C++ options manually, and have added the Gradle line packagingOptions.doNotStrip '**.so' as well. But still this problem persists.

What would cause this behavior in Visual Studio and how can I fix it?

Bungles
  • 1,969
  • 2
  • 25
  • 54

1 Answers1

0

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.

So you have to make NativeActivity c++ app be attached to a Xamarin Managed App(Acttach to Process)to get what you want.

1) create a c# xamarin android app and then input that xamarin managed apk file into the NativeActivity c++ app's Properties-->Debugging-->Package To Launch

2) start Xamarin c# app first and then make the Xamarin debugger active. While the managed app is still running or being debugged, right-click on the native library project and select Debug --> Attach to Android process.

Here is an example provided by Richard Walters and he provided the detailed info.

Sara Liu - MSFT
  • 6,007
  • 1
  • 21
  • 27
  • I have another Android app which is also just a NativeActivity, and Visual Studio can set breakpoints and debug. The only difference between the two apps is the one that works was built with ANT and the one that doesn't debug was built with Gradle. They both deploy and run the app, it's just debugging that's not working. – Bungles Mar 25 '21 at 16:53
  • Try to add the the location of the `xxx.pdb` file under Tools-->Options-->Debugging-->Symbols-->Symbol file location. After that, while debugging, please open menu Debugging-->Windows-->Modules to check whether the pdb file is loaded or not. You could also right-click on that dll-->load symbol – Sara Liu - MSFT Mar 26 '21 at 08:21