Ask Your Question
4

How can I ensure that Visual Studio is able to debug a hybrid app that uses both Java and C++ on an Android device?

asked 2023-06-06 13:52:37 +0000

djk gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2023-06-06 14:15:02 +0000

pufferfish gravatar image

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.
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-06-06 13:52:37 +0000

Seen: 9 times

Last updated: Jun 06 '23