Here are the steps to ensure that Visual Studio is able to debug a hybrid app that uses both Java and C++ on an Android device:
- Install Visual Studio with the Android development workload and the Xamarin tools.
- Install the Android SDK and NDK using the Android SDK Manager.
- Create a new Xamarin.Android project in Visual Studio.
- In the project properties, go to Android Options > Advanced and select "Use LLVM compiler" for both Debug and Release configurations.
- In the project properties, go to Android Options > Linker and select "Sdk and User Assemblies" for both Debug and Release configurations.
- Add the C++ source files to the project as a separate C++ library project.
- Add the C++ library project as a reference to the main Xamarin.Android project.
- Build the solution.
- Connect your Android device to your computer using a USB cable.
- Enable USB debugging on your device.
- Set the Xamarin.Android project as the startup project.
- From the Debug menu, select "Attach to Process".
- In the "Select Code Type" dialog, select "Android Native", and click "Select".
- Select your device from the list of available devices, and click "Attach".
- Set breakpoints in your C++ code and Java code.
- Run your app on your Android device.
- When your app hits a breakpoint, Visual Studio will automatically switch to the Debug view and display the call stack and variable values.