Debugging Arbitrary APK Files with Visual Studio

This tutorial shows how to quickly debug an APK on an Android device without creating a separate VisualGDB project.

Before we begin, ensure that VisualGDB 3.1 or later is installed with the Android Edition.

In this tutorial we will use an APK file from the Android quickstart tutorial project. You can use any APK file as long as it is debuggable.

  1. Start Visual Studio. Connect an Android device or start an Android Virtual Device. Go to Android->Debug a Custom APK File.01-quickdebug
  2. Browse for the APK file to debug. You can find it in the bin directory of Android projects. Also make sure it is a debug version of the APK file, otherwise it cannot be debugged.02-quickdebugwindow03-openapk
  3. Check the option boxes if relevant. Add a preset name if you want to use those settings later on as well. When done, press ‘Debug’.03b-openapk
  4. Now VisualGDB will deploy the APK file to the Android device and start the debug session. 04-startdebugging
  5. The APK has been started on the device and already the LogCat and GDB Session windows are receiving messages. Click on the ‘Break All’ button. 05-debugging
  6. Click on ‘Break’ as that is our intention. 06-sigint
  7. Once the app is paused go to the ‘GDB Session’ window and click on the ‘Show a list of all source files’ button. 07-sourcebutton
  8. Choose the source file you want to put a breakpoint in. Our example project only has one source file, hence we choose this. 08-allsources
  9. Set a breakpoint in the source file. 09-breakpoint
  10. Trigger the breakpoint. With the quickstart example, just tap on the screen. 10-avd
  11. When the breakpoint triggers you will be able to use the normal debugging features of Visual Studio just like with other projects. 11-breaked