# android-notes/Cockroach

降低Android非必要crash

Repository: https://github.com/android-notes/Cockroach
Canonical: https://ross.abutalabs.com/products/android-notes-cockroach
Language: Java
License: MIT
License Family: permissive
Topics: android, crash
Last push: 2023-05-28T16:36:02+00:00

## Health v2 (maintenance only)
Score: 23/100 (v2, computed 2026-09-02T17:46:02.011165+00:00)
- activity 0, release rhythm 8, longevity 100
- inputs: {"age_days": 3487, "days_push": 1193, "days_rel": null, "gap_med": null, "n_releases_24m": 0}
- flags: none
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 3255, forks 449 (observed 2026-08-28T04:07:52.222742+00:00)

## What it is
Cockroach is an Android library (Java) that prevents unnecessary app crashes by intercepting exceptions thrown in the main thread's message loop and rescuing the app instead of letting Android's default handler kill the process. It is aimed at non-fatal bugs—such as device-specific system quirks or errors inside onClick handlers and third-party SDK initialization—where silently ignoring the exception is better than crashing the whole app.

## Use cases
- prevent android app from crashing on uncaught exceptions
- catch main thread exceptions in android app
- reduce crash rate of my android app
- ignore non-fatal exceptions instead of killing the process
- global exception handler library for android
- keep app running when startActivity throws
- handle third-party sdk init crashes gracefully

## When to choose
- You want an app-level safety net so exceptions in click callbacks, lifecycle code, or third-party SDK init don't kill the whole app
- Your crash reports show device-specific or system bugs that cannot be fixed in code and are safe to swallow
- You need to reduce crash rate for non-critical features where a crash is worse than a skipped action

## When to avoid
- You need to surface and fix root causes rather than mask potentially serious bugs behind silent exception swallowing
- Exceptions thrown during view measure/layout/draw or RecyclerView ViewHolder binding can leave the UI (ViewRootImpl) in a broken state
- You are looking for crash reporting/analytics rather than crash prevention

## Facets
- artifact type: library
- maturity: stable
- function: error-handling
- domain: mobile-development, android-tools
- platform: -
- tags: crash-prevention, exception-handling, fault-tolerance, main-thread, uncaught-exception, android-library, app-stability, crash-handler, android

## Member repositories
- android-notes/Cockroach (main) score 23

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:07:52.222742+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-30T07:24:22.896580+00:00, confidence not recorded.
  - readme: https://github.com/android-notes/Cockroach (fetched 2026-08-28T04:07:52.222742+00:00, sha 9e4ca8448137)
- Data as of 2026-08-30T08:39:29.467469+00:00.
