anr-audit-and-fix
它能做什么
这个技能检查 Android 代码中导致应用无响应(ANR)卡死的风险,并解释 ANR 堆栈转储。适合在应用中遇到卡死或 ANR 报告的 Android 开发者。
适用场景
- ✓当你想扫描 Android 代码中阻塞主线程的工作时。
- ✓当你有一份 ANR 堆栈转储或跟踪记录,并想知道是什么原因导致的时候。
- ✓当 Google Play 或你的崩溃工具报告 ANR 错误,并且你需要可能的修复方法的时候。
技能链接
https://github.com/android/skills/blob/main/performance/anr-audit-and-fix/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“这是我们应用的一份 ANR 跟踪记录。请告诉我原因是什么,以及应该修复什么。”
每周 5 个新技能,1 分钟读完。
工作原理
对于代码,该技能会列出有风险的调用,证明它们在哪个线程上运行,以及它们是否真的会阻塞,然后对每项进行评级。对于跟踪记录,它会遵循既定的跟踪分析指南,并仅根据日志证据撰写报告。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Select the execution path matching the user's request:
1. Path A: Static codebase ANR risk audit
When auditing source files or scanning for thread-blocking operations:
- Follow references/risk_analysis_guide.md step by step: list candidates, prove the executing thread (trace callers when the thread depends on them), prove the call blocks, then attribute and grade. Report only candidates that pass these checks; list the dismissed ones separately with a one-line reason.
- Evaluate off-main-thread mutations of attached Views not merely as crash risks (
CalledFromWrongThreadException), but as Sync Barrier Leak ANR risks with their own proof (off-main execution plus an attached View).
2. Path B: Trace-driven diagnosis and remediation
When analyzing ANR traces or stack dumps:
- Diagnose systematically using references/trace_analysis_guide.md and format the report with references/anr_trace_report_template.md.
- Base findings strictly on log evidence. Propose application fixes only for
APP_DEFECTorAPP_RESOURCE_OVERLOAD(never forEXTERNAL_BOTTLENECK).
常见问题
它会列出每一个慢调用吗?
不会。它只报告能够证明的风险,并把被排除的项目单独列出,附上简短理由。
它会为每个 ANR 提出修复方案吗?
只会针对应用自身的问题。外部瓶颈等应用之外的原因,不会给出应用端的修复方案。
它涵盖崩溃和掉帧吗?
不涵盖。非 ANR 崩溃、掉帧和系统跟踪不在本技能的范围之内。
详情
作者的原始描述
Audits Android codebases for ANR risks and diagnoses ANR stack dumps. Use this skill when scanning Android code for ANR risks or triaging ANR stack dumps. Don't use for non-ANR crashes, dropped frames, general CPU profiling, or Perfetto system traces.
repo: android/skills
热度
- GitHub 星标
- 10k
- 排名
- #11926
- 许可证
- Apache-2.0
- 更新时间
- 2026/10/29
评论
- …
同一仓库的更多技能
agp-9-upgrade
10k帮你的智能体把 Android 应用升级到 Android Gradle Plugin 9,并处理其中的破坏性变更。不适用于多平台项目。
camerax
10k帮你的智能体使用 CameraX 构建 Android 相机功能,包括视频录制、硬件控制以及 ML Kit 和 Media3 效果。
android-for-cars-parked-apps
10k帮你的智能体把 Android 视频、游戏或浏览器应用调整为可在 Android Auto 和 Android Automotive 上以停放应用形式运行。
appfunctions
10k帮你的智能体在 Android 应用中找到关键工作流,并把它们暴露为 AI 智能体和语音命令可以运行的 AppFunctions。