Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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:

  1. Install Visual Studio with the Android development workload and the Xamarin tools.
  2. Install the Android SDK and NDK using the Android SDK Manager.
  3. Create a new Xamarin.Android project in Visual Studio.
  4. In the project properties, go to Android Options > Advanced and select "Use LLVM compiler" for both Debug and Release configurations.
  5. In the project properties, go to Android Options > Linker and select "Sdk and User Assemblies" for both Debug and Release configurations.
  6. Add the C++ source files to the project as a separate C++ library project.
  7. Add the C++ library project as a reference to the main Xamarin.Android project.
  8. Build the solution.
  9. Connect your Android device to your computer using a USB cable.
  10. Enable USB debugging on your device.
  11. Set the Xamarin.Android project as the startup project.
  12. From the Debug menu, select "Attach to Process".
  13. In the "Select Code Type" dialog, select "Android Native", and click "Select".
  14. Select your device from the list of available devices, and click "Attach".
  15. Set breakpoints in your C++ code and Java code.
  16. Run your app on your Android device.
  17. When your app hits a breakpoint, Visual Studio will automatically switch to the Debug view and display the call stack and variable values.