Looking to learn about debugging mobile apps? You're in the right place. Here, you'll learn how to debug an Android app with Perfecto's Android debugger tool.
Debugging Mobile Apps With Perfecto's Remote Device Access
Perfecto's Remote Device Access feature provides the ability to debug Android mobile apps on real devices under realistic conditions. This speeds the process of validating new features and fixing bugs that only show up under specific environments or conditions.
Watch the video below, or follow the step-by-step guide below to learn how to debug an app.
How to Debug an Android App
- Install Android Studio
- Install Perfecto plugin for Android Studio
- Download sample app (.apk)
Download the app as .zip file and extract it.
Debug an Android App on a Mobile Device
1. Open the android-calculator-master app project.
2. Click the ‘Launch Mobile’ icon in the Perfecto Android Studio plugin toolbar.
3. Select an Android device and click “open”
4. Switch to the Widgets menu and click the ‘DevTunnel’ widget.
5. If you have not done so already, download and install the DevTunnel installer. Wait for the installation to complete.
6. Click the ‘Start Dev Tunnel Session’ step to establish a direct connection to the device.
7. Open the application code file, here it is in the file MainActivity.java
8. Set the breakpoints in the code where you suspect that there are problems.
9. While Android Studio is focused on the app code, click on the Debug icon.
10. Select the Android device you opened from the Perfecto cloud plugin that appears in the Select Deployment Target window and click ‘OK’ to launch the application in debug mode on the device.
11. After Gradle build is successful, note that Android Studio utilizes ADB commands against the device to copy .apk resources to the device, and launch the app in debug mode.
12. Interactively, exercise the application and activate the suspicious interface elements. In this case, it is the input field of the “Split Number”. Enter a number, then delete it, and the application crashes with an Exception.
13. When we enter ‘3’ into the field – the debugger stops at the breakpoint, stepping through the method shows that it works fine.
14. Now, we delete the ‘3’ in the field. The debugger again stops at the breakpoint. And we examine the variable values.
15. Performing a “step over (F8)” command causes the application to crash. So, we know that we need to analyze and understand what is causing the crash.
16. The problem seems to be with the call to “Integer.parseInt(s.toString())” when the string is an empty string (as noted above). So, we change the code to check for this occurrence:
17. Rerun the app with the debugger and note that it works as planned even when the “input” is empty.
18. When finished, click the ‘Disconnect’ button from the Perfecto Widgets frame to close your DevTunnel session.
19. Click the ‘X’ on the device window to release the mobile device.
You now know how to debug an app when you connect a real, cloud-based mobile device from the Perfecto Lab into your IDE. Try it out with the next feature you’re building or run some of your own tests on different devices to see if your apps pass with flying colors on other platforms.
Try Debugging Apps With Perfecto
You can test and debug Android apps, iOS apps, and web browsers all within the Perfecto cloud.
ML-powered test failure analysis makes app debugging easier with Perfecto. With Perfecto, you get:
- The true failure reason for your tests.
- Actionable steps for fast debugging — all within your IDE!
- And you don't have to reproduce the bugs either.
Give it a try and get started today with your free Perfecto trial.
- Debugging From Your IDE is Much Easier Now – It's On the Cloud
- 3 Steps to Debug and Test Your iOS App in the Cloud
- Mobile Testing With Appium: 3 Advanced Automation Techniques