anr¶
Retrieving Application Not Responding (ANR) reports for a package from the
device's DropBox (adb shell dumpsys dropbox --print data_app_anr
system_app_anr) — the same store adb bugreport and DropBoxManager read.
get_anr_reports parses each ====-delimited entry (timestamp/tag header,
Key: value header block, trace body), filters to the entries whose
recorded Process: / Package: matches the requested package, and returns
them newest first with a bounded limit. include_traces=false drops the
thread dumps for small headers-only responses. No root required; DropBox is
size-capped and rotates, so an empty result means "none currently stored".
adb_automation_mcp.modules.anr.tools
¶
Module-level, statically-introspectable tool functions for the anr module.
Kept as plain top-level functions, never closures, so that documentation tooling and the registry meta-test can both introspect them directly.
get_anr_reports(ctx: Context, serial: str, package_name: str, limit: int = 5, include_traces: bool = True) -> AnrReportList
async
¶
Get a package's ANR reports from the device's DropBox
(adb shell dumpsys dropbox --print data_app_anr, and again for
system_app_anr).
DropBox is the system store DropBoxManagerService keeps for crash / ANR
records (the same source adb bugreport and DropBoxManager read).
dumpsys dropbox --print accepts one tag at a time, so this queries both
ANR tags, parses each entry's header block and body, and returns the ones
whose recorded process/package matches package_name, newest first. No
root required. Reading only — DropBox isn't modified.
DropBox is size-capped and rotates, so ANRs older than roughly the last day or the last few hundred records may already have aged out; an empty result means "none currently in DropBox", not "this app never ANR'd".
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
serial
|
str
|
The target device's adb serial (see list_connected_devices). |
required |
package_name
|
str
|
The package whose ANRs to fetch, e.g. "com.example.app". Matched against each entry's Process:/Package: header. |
required |
limit
|
int
|
Maximum number of reports to return, newest first, 1-50 (default 5). |
5
|
include_traces
|
bool
|
When true (default) each report carries its full trace body (thread dumps, CPU usage), capped in length. Set false to get just the headers and subject line — much smaller responses when you only need to know that/when ANRs happened. |
True
|
Returns:
| Type | Description |
|---|---|
AnrReportList
|
The serial, package_name, count, and reports — each with tag ("data_app_anr" / "system_app_anr"), timestamp (device-local, verbatim), process, package, pid, uid, flags, subject (the "ANR in ..." line when present), size_bytes, and trace (null when include_traces is false). An empty reports list is a normal result. |
Error handling
A blank package_name or an out-of-range limit raises INVALID_ARGUMENT before anything runs. An unknown serial or unresponsive adb binary raises DEVICE_NOT_FOUND/ADB_UNAVAILABLE. A permission rejection raises PERMISSION_DENIED; any other non-zero exit raises BACKEND_ERROR. "(No entries found.)" is a normal empty result, not an error.
Example
Called with serial="emulator-5554", package_name="com.example.app", include_traces=false. A typical response:
{
"status": "success",
"message": "1 ANR report for com.example.app on emulator-5554 (newest 2026-09-06 16:52:25).",
"data": {
"serial": "emulator-5554",
"package_name": "com.example.app",
"count": 1,
"reports": [
{
"tag": "data_app_anr",
"timestamp": "2026-09-06 16:52:25",
"process": "com.example.app",
"package": "com.example.app",
"pid": 12345,
"uid": 10234,
"flags": "0x30c8be45",
"subject": "ANR in com.example.app (com.example.app/.MainActivity)",
"size_bytes": 40219,
"trace": null
}
]
},
"error": null
}
Source code in src/adb_automation_mcp/modules/anr/tools.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | |