Skip to content

Checking your reading list…

Retry verification

Stay curious. Build better.

Appearance

Choose how BestHub looks on this device.

Changes apply immediately.

Search articles

Open Discover with these filters

Suggested searches

Android Debugging Techniques: Operations, Practices, and Principles
Mobile Development 15 min read

Android Debugging Techniques: Operations, Practices, and Principles

The guide explains Android debugging fundamentals, covering run and attach modes, essential operations like stepping and breakpoints, best practices for inspecting variables and reducing compile time, the underlying ADB and JDWP protocols, and troubleshooting common issues such as breakpoint loss and port conflicts.

This article provides a comprehensive guide to Android debugging, an essential skill for developers that significantly improves development efficiency.

The content covers four main areas:

1. Debug Operations : Introduction to Debug Run and Attach to Process modes, with detailed explanations of common debugging operations including Show Execution Point, Step Over, Step Into, Step Out, Drop Frame, Run to Cursor, and Evaluate Expression. The article also covers different breakpoint types: line breakpoints, field breakpoints, exception breakpoints, and method breakpoints.

2. Debug Practices : How debugging helps developers through "viewing information" and "reducing compilation times". Topics include viewing local and global variables, examining stack traces, runtime code modification using setValue and Evaluate Expression, log breakpoints, conditional breakpoints, exception breakpoints, multi-threaded debugging, and debugging Release packages using ADB forward and JDWP protocols.

3. Debugging Principles : The debugging process relies on ADB (Android Debug Bridge) and JDWP (Java Debug Wire Protocol) for communication between the debugger and the virtual machine. The article explains the ADB architecture consisting of ADB Server, ADB Client, and ADB Daemon, and provides detailed analysis of JDWP protocol packets including command packets and reply packets with their header structures.

4. Common Issues : Solutions for breakpoint disconnection on certain devices, "Attach to Process" failures due to port conflicts, and performance issues when using method breakpoints.

Key commands mentioned include: adb shell am set-debug-app -w --persistent 包名 for enabling debug wait mode, adb shell am clear-debug-app for disabling it, adb shell dumpsys activity top | grep ACTIVITY for finding the current activity, and adb forward tcp:5005 jdwp:PID for connecting the debugger to a process.

About this article

For questions about attribution, corrections or content rights, please contactadmin@besthub.devand we will review it promptly.

Report an issue with this article
breakpointsAndroid StudioADBAndroid debuggingDebugging PrinciplesjdwpMulti-threading Debugging

Reader feedback

Was this useful?

Useful0

Discussion 0

Questions, practical examples and thoughtful responses.

Open full discussion