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.
- Start Visual Studio. Connect an Android device or start an Android Virtual Device. Go to Android->Debug a Custom APK File.
- 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.
- 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’.
- Now VisualGDB will deploy the APK file to the Android device and start the debug session.
- 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.
- Click on ‘Break’ as that is our intention.
- Once the app is paused go to the ‘GDB Session’ window and click on the ‘Show a list of all source files’ button.
- Choose the source file you want to put a breakpoint in. Our example project only has one source file, hence we choose this.
- Set a breakpoint in the source file.
- Trigger the breakpoint. With the quickstart example, just tap on the screen.
- When the breakpoint triggers you will be able to use the normal debugging features of Visual Studio just like with other projects.