EN | ZH

# Android dynamic debugging¶

## Android Debugging Basics¶

In general, Android determines whether an application can be debugged according to the following order.

1. Check if the ro.debuggable in boot.img is 1, and if it is 1, any application in the phone can be debugged.
2. Otherwise, detect the corresponding application in AndroidManifest.xml <application> Whether the element contains android:debuggable="true", if any, will enable debugging support.

Naturally, we have two ways to make an application debugged.

1. Unpack an apk file, at <application> Add android:debuggable="true" to the element, then repackage and sign.
2. Modify the ro.debuggable in boot.img to 1.

Generally speaking, because the former requires us to modify the application every time, it is more troublesome, we prefer the latter.

For the latter, we need the root phone and brush in the relevant image. (!! Find a suitable article!!)

In addition, the emulator generated by Andoird AVD is set to 1 by default with ro.debuggable.

The value of ro.debuggable can be queried according to the following command:

adb shell getprop ro.debuggable


## Basic Debugging Tools¶

### DDMS¶

DDMS (Dalvik Debug Monitor Service) is the Dalvik virtual machine debugging monitoring service, which can monitor the status and results of Android programs during operation, which can greatly speed up the efficiency of our program analysis. This is a tool provided by the Android SDK, which has a device screen capture, view running thread information, file browsing, Logcat, Method Profiling, broadcast status information, analog phone calls, receiving SMS and other functions. This tool is generally located in the tools directory of the Android SDK, where ddms.bat is used to start DDMS. The more important functions in DDMS are mainly

• File browsing, we can observe and analyze the program's generation, modification, and deletion of files during execution.
• Logcat, which can output some debugging information of the software.
• Method Profiling, which tracks the execution flow of the program.

### IDEA/Android Studio¶

Install the smaliidea plugin to dynamically debug smali.

I love to crack.