Automated summary
This skill sets up crash and ANR monitoring using Crashlytics, StrictMode, and structured logging for Android applications.
Strengths
- Full integration with Firebase Crashlytics for fatal and non-fatal crashes
- ANR detection via custom watchdog and StrictMode
- Structured logging with Timber for contextual logs
Limitations
- Requires an existing Firebase project and Android setup
- ANR detection may not work on all devices in production
- Depends on a specific version of Firebase Crashlytics library
Best used when preparing a release or diagnosing performance issues in production.
Avoid if the app does not use Firebase or if an alternative monitoring system is already in place.
Security analysis
SafeThe skill provides standard setup instructions for crash monitoring tools like Firebase Crashlytics, ANR detection, and structured logging. It does not contain any destructive commands, data exfiltration, obfuscated payloads, or instructions to disable safety features. All code snippets are benign and follow typical mobile development practices.
No concerns found
How this analysis is madeExamples
Please complete Firebase Crashlytics integration following the Firebase Crashlytics Setup section.Add StrictMode and ANR Watchdog following the ANR Analysis section.Unify log format using structured logging as per the Structured Logging section.id: crash_monitoring name: Crash Monitoring description: Crashlytics 設定、ANR 分析與結構化日誌
Crash Monitoring (當機監控)
Instructions
- 確認需求屬於當機/ANR/日誌監控
- 依照下方章節順序套用
- 一次只調整一種監控或警報設定
- 完成後對照 Quick Checklist
When to Use
- Scenario D:效能問題排查
- Scenario E:發布前監控準備
Example Prompts
- "請依照 Firebase Crashlytics Setup,完成 Crashlytics 整合"
- "用 ANR Analysis 章節加入 StrictMode 與 ANR Watchdog"
- "請依 Structured Logging 章節統一日誌格式"
Workflow
- 先完成 Crashlytics 基本設定與 Custom Keys
- 再加入 ANR 與 Structured Logging
- 最後用 Dashboard & Alerting 與 Quick Checklist 驗收
Practical Notes (2026)
- Release 前先確立 Crash/ANR 的告警門檻
- 重要流程必有結構化事件與關鍵鍵值
- Non-Fatal 記錄以高價值事件為主
Minimal Template
目標:
監控範圍:
告警門檻:
事件欄位:
驗收: Quick Checklist
Firebase Crashlytics Setup
基本設定
// build.gradle.kts (app)
plugins {
id("com.google.firebase.crashlytics")
}
dependencies {
implementation(platform("com.google.firebase:firebase-bom:32.7.0"))
implementation("com.google.firebase:firebase-crashlytics-ktx")
implementation("com.google.firebase:firebase-analytics-ktx")
}
Custom Keys
// 記錄使用者狀態
Firebase.crashlytics.apply {
setUserId("user_123")
setCustomKey("subscription_tier", "premium")
setCustomKey("feature_flags", "new_checkout:true")
}
Non-Fatal Logging
// 記錄非致命錯誤
try {
riskyOperation()
} catch (e: Exception) {
Firebase.crashlytics.recordException(e)
// 繼續正常流程
}
// 帶上下文的 Non-Fatal
Firebase.crashlytics.log("Starting payment flow")
try {
processPayment()
} catch (e: PaymentException) {
Firebase.crashlytics.apply {
setCustomKey("payment_amount", amount)
setCustomKey("payment_method", method)
recordException(e)
}
}
ANR Analysis
StrictMode (Debug)
class MyApplication : Application() {
override fun onCreate() {
super.onCreate()
if (BuildConfig.DEBUG) {
StrictMode.setThreadPolicy(
StrictMode.ThreadPolicy.Builder()
.detectDiskReads()
.detectDiskWrites()
.detectNetwork()
.penaltyLog()
.penaltyDeath() // 強制 Crash
.build()
)
StrictMode.setVmPolicy(
StrictMode.VmPolicy.Builder()
.detectLeakedClosableObjects()
.detectActivityLeaks()
.penaltyLog()
.build()
)
}
}
}
ANR Watchdog
class ANRWatchDog(private val timeoutMs: Long = 5000) : Thread() {
private val mainHandler = Handler(Looper.getMainLooper())
private var tick = 0
private var reported = false
override fun run() {
while (!isInterrupted) {
val currentTick = tick
mainHandler.post { tick++ }
Thread.sleep(timeoutMs)
if (currentTick == tick && !reported) {
reported = true
val stackTraces = Looper.getMainLooper().thread.stackTrace
Firebase.crashlytics.log("ANR Detected")
Firebase.crashlytics.recordException(ANRException(stackTraces))
}
}
}
}
Structured Logging
Timber Setup
class MyApplication : Application() {
override fun onCreate() {
super.onCreate()
if (BuildConfig.DEBUG) {
Timber.plant(Timber.DebugTree())
} else {
Timber.plant(CrashlyticsTree())
}
}
}
class CrashlyticsTree : Timber.Tree() {
override fun log(priority: Int, tag: String?, message: String, t: Throwable?) {
if (priority >= Log.INFO) {
Firebase.crashlytics.log("[$tag] $message")
}
t?.let {
Firebase.crashlytics.recordException(it)
}
}
}
Log Levels 使用規範
| Level | 使用場景 | 例子 | |-------|---------|------| | VERBOSE | Debug 專用細節 | API Response body | | DEBUG | 開發除錯 | ViewModel state changes | | INFO | 重要里程碑 | User login success | | WARN | 潛在問題 | Retry attempt | | ERROR | 可恢復錯誤 | Network timeout |
Dashboard & Alerting
Crashlytics Velocity Alerts
Firebase Console > Crashlytics > Settings
- Enable velocity alerts
- Set threshold: 1% of sessions
Custom Metrics
// 追蹤關鍵指標
Firebase.analytics.logEvent("checkout_started") {
param("cart_value", cartValue)
}
Firebase.analytics.logEvent("checkout_completed") {
param("payment_method", method)
param("time_to_complete_ms", duration)
}
Quick Checklist
- [ ] Crashlytics 整合完成
- [ ] Custom Keys 設定 (User tier, Feature flags)
- [ ] Non-Fatal 記錄重要異常
- [ ] StrictMode 在 Debug 啟用
- [ ] Timber 統一日誌
- [ ] Velocity Alerts 設定
From the file to a first result
The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.
View the source and supporting filesThis download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.
1. Download the file
Download SKILL.mdFrom the root of a test project, save the file as .skill-downloads/crash-monitoring-mm5t8c7c/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.
Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.
mkdir -p '.skill-downloads/crash-monitoring-mm5t8c7c' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/crash-monitoring-mm5t8c7c/download' --output '.skill-downloads/crash-monitoring-mm5t8c7c/SKILL.md.part' && mv '.skill-downloads/crash-monitoring-mm5t8c7c/SKILL.md.part' '.skill-downloads/crash-monitoring-mm5t8c7c/SKILL.md'2. Check prerequisites
Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.
No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.
The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.
3. Load the skill
This file does not provide a usable name/description header for this native procedure. It remains available to download and inspect; use the manual method below.
Manual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.
4. Try a first task
Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:
Read .skill-downloads/crash-monitoring-mm5t8c7c/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.
React Hook Form Best Practices
Development
Master React Hook Form: avoid anti-patterns, manage subscriptions, and handle reset, dirty state, and controlled inputs correctly.
Emotion to Mantine Migration
Development
Migrate Emotion styled-components to Mantine components with style props and CSS modules. Use when converting .styled.tsx files or removing @emotion imports.
Scope Creep Detector
Development
Analyzes git diffs against a stated intent to detect scope creep, unrelated files, broad PRs, and oversized changes, then suggests keep, split, or justify actions.