Android Studio for Platform (ASfP) provides a powerful debugger that lets you:
- Select a device to debug on.
- Set breakpoints in your Java, Kotlin, and C/C++ code.
- Examine variables and evaluate expressions at runtime.
Before you use the debugger, you must flash your build to a device or emulator.
App process (Java/Kotlin) debugging
To debug a Java or Kotlin application process:
Set breakpoints in your Java or Kotlin code within ASfP.
Select Run > Attach Debugger to Android Process from the menu.
In the Choose Process dialog, make sure the Debug type is set to Java Only.
Select your device from the list.
Choose the specific application process you want to debug.
Click OK.
Interact with the application on your device to hit the breakpoints.
System process (C/C++) debugging
To debug a system process written in C or C++:
Verify that you have only one device or emulator running.
Open a terminal and run
adb root
from your AOSP checkout root:bash adb root
Set breakpoints in your C/C++ code within ASfP.
Select Run > Attach Debugger to Android Process from the menu.
In the Choose Process dialog, change the Debug type to Native Only or Dual (Java + Native).
Check the Show all processes box to see system processes.
Select your device from the list.
Choose the specific system process you want to debug (such as
surfaceflinger
orsystem_server
).Click OK.
The debugger attaches to the process. Interact with the device to hit your breakpoints.