
Sentry Android Sdk
Wire Sentry Crons check-ins for Android background jobs, sync workers, and scheduled tasks so missed runs alert you in production.
Overview
Sentry Android SDK is an agent skill for the Operate phase that explains how to send Sentry Crons check-ins from Android apps using the Java SDK.
Install
npx skills add https://github.com/getsentry/sentry-for-ai --skill sentry-android-sdkWhat is this skill?
- Documents Sentry Crons via core Java SDK APIs on Android—no dedicated Android Crons module
- CheckInUtils.withCheckIn() pattern with experimental API note versus manual stable Pattern B
- Duration reported in seconds as Double, not milliseconds
- Rate limit called out: 6 check-ins per minute per monitor per environment
- Kotlin examples for WorkManager-style jobs requiring manual wiring
- 6 check-ins per minute per monitor per environment rate limit
- Duration parameter in seconds as Double
Adoption & trust: 1.1k installs on skills.sh; 197 GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
Your Android app runs critical background jobs but you only notice failures when users complain, not when a scheduled worker stops checking in.
Who is it for?
Solo developers shipping Kotlin/Android apps already instrumented with io.sentry:sentry-android.
Skip if: Greenfield projects with no Sentry project or teams wanting fully automatic WorkManager instrumentation without manual code.
When should I use this skill?
User implements or debugs Sentry Crons, captureCheckIn, or CheckInUtils on Android.
What do I get? / Deliverables
You implement monitor slugs with correct IN_PROGRESS and completion statuses so Sentry alerts on missed or failed scheduled work.
- Kotlin check-in wiring around scheduled or background work
- MonitorConfig / schedule snippets aligned with Sentry Crons docs
Recommended Skills
Journey fit
Operate is where shipped Android apps need observability for periodic work, not just crash reports. Monitoring subphase matches Sentry Crons semantics: IN_PROGRESS, OK, ERROR check-ins and overdue monitor alerts.
How it compares
Operational check-in skill for mobile cron monitors, not a replacement for Sentry error/crash setup or full APM suite configuration.
Common Questions / FAQ
Who is sentry-android-sdk for?
Indie Android developers using Sentry who need Crons coverage for background and scheduled tasks.
When should I use sentry-android-sdk?
Use it in Operate when adding or debugging Sentry monitor check-ins around sync workers, periodic cleanup, or job success SLAs.
Is sentry-android-sdk safe to install?
It documents SDK calls only; confirm versions against your build and review the Security Audits panel on this page before enabling network-sending code paths.
SKILL.md
READMESKILL.md - Sentry Android Sdk
# Crons / Monitors — Sentry Android SDK > **Minimum SDK:** `io.sentry:sentry-android` (any version — uses core Java SDK APIs) > **Status:** Stable (`Sentry.captureCheckIn()`); `CheckInUtils` is `@ApiStatus.Experimental` > **Docs:** https://docs.sentry.io/platforms/java/crons/ (Android-specific page returns 404) --- ## Overview Sentry Crons lets you monitor scheduled jobs, background sync workers, and periodic tasks. A **check-in** signals to Sentry that a job started (`IN_PROGRESS`) and completed (`OK`) or failed (`ERROR`). If a check-in is missed or overdue, Sentry fires an alert. **Key facts for Android:** - Uses the core Java SDK — no Android-specific integration or module exists - No `SentryWorker`, no WorkManager adapter, no AlarmManager wrapper — all wiring is manual - `duration` is in **seconds as a Double**, not milliseconds - `CheckInUtils` helper is `@ApiStatus.Experimental` (API may change between releases) - Rate limit: 6 check-ins per minute per monitor per environment --- ## Pattern A — `CheckInUtils.withCheckIn()` (Recommended) `CheckInUtils` is the simplest API. It sends `IN_PROGRESS` on entry, automatically calculates duration, and sends `OK` on success or `ERROR` on exception. > **Note:** `CheckInUtils` carries `@ApiStatus.Experimental`. Prefer Pattern B for production code where you need stable guarantees. ```kotlin import io.sentry.CheckInUtils import io.sentry.MonitorConfig import io.sentry.MonitorSchedule // Minimal — slug only CheckInUtils.withCheckIn("nightly-sync") { performNightlySync() } // With upsert config — creates or updates the monitor automatically val monitorConfig = MonitorConfig(MonitorSchedule.crontab("0 2 * * *")).apply { setCheckinMargin(5L) // alert if check-in is 5+ minutes late setMaxRuntime(60L) // alert if running for 60+ minutes setTimezone("UTC") } CheckInUtils.withCheckIn("nightly-sync", "production", monitorConfig) { performNightlySync() } ``` **Full signature:** ```kotlin CheckInUtils.withCheckIn( monitorSlug: String, // required — must match slug in Sentry dashboard environment: String?, // null → uses SDK default environment monitorConfig: MonitorConfig?, // null → no upsert; monitor must exist in dashboard callable: Callable<T> ): T ``` --- ## Pattern B — Manual Two-Step (Full Control) Send `IN_PROGRESS` before the job starts, then `OK` or `ERROR` when it finishes. This gives you full control over duration and error handling. ```kotlin import io.sentry.CheckIn import io.sentry.CheckInStatus import io.sentry.MonitorConfig import io.sentry.MonitorSchedule import io.sentry.Sentry fun runDatabaseBackup() { val startedAt = SystemClock.elapsedRealtime() // 1. Signal that the job has started val startCheckIn = CheckIn("db-backup", CheckInStatus.IN_PROGRESS) val checkInId = Sentry.captureCheckIn(startCheckIn) val status: CheckInStatus try { performBackup() status = CheckInStatus.OK } catch (e: Exception) { Sentry.captureException(e) // also capture the error for Sentry Issues status = CheckInStatus.ERROR } // 2. Signal completion — link via checkInId val elapsed = SystemClock.elapsedRealtime() - startedAt val done = CheckIn(checkInId, "db-backup", status).apply { // ⚠️ Duration is in SECONDS (Double), not milliseconds setDuration(elapsed / 1000.0) setMonitorConfig( MonitorConfig(MonitorSchedule.crontab("0 3 * * *")).apply { setTimezone("UTC") setMaxRuntime(45L) setCheckinMargin(10L) } ) } Sentry.captureCheckIn(done) } ``` > **⚠️ Duration is in SECONDS, not milliseconds.** Always divide elapsed milliseconds by `1000.0`: > ```kotlin > setDuration(SystemClock.elapsedRealtime() - startMs) / 1000.0) // CORRECT > setDuration(SystemClock.elapsedRealtime() - startMs) // WRONG — 1000× too large