sentry-android-sdk

Full Sentry SDK setup for Android. Use when asked to "add Sentry to Android", "install sentry-android", "setup Sentry in Android", or configure error monitoring, tracing, profiling, session replay, or logging for Android applications. Supports Kotlin and Java codebases.

By getsentry · 2,099 installs

npx skills add getsentry/sentry-for-ai --skill sentry-android-sdk

Source repository · Upstream listing

[All Skills](../../SKILL TREE.md) [SDK Setup](../sentry sdk setup/SKILL.md) Android SDK Sentry Android SDK Opinionated wizard that scans your Android project and guides you through complete Sentry setup — error monitoring, tracing, profiling, session replay, logging, and more. Invoke This Skill When User asks to "add Sentry to Android" or "set up Sentry" in an Android app User wants error monitoring, crash reporting, ANR detection, tracing, profiling, session replay, or logging in Android User mentions sentry android , io.sentry:sentry android , mobile crash tracking, or Sentry for Kotlin/Java Android User wants to monitor native (NDK) crashes, application not responding (ANR) events, or app startup performance Note: SDK versions and APIs below reflect current Sentry docs at time of writing ( io.sentry:sentry android:8.33.0 , Gradle plugin 6.1.0 ). Always verify against [docs.sentry.io/platforms/android/](https://docs.sentry.io/platforms/android/) before implementing. Phase 1: Detect Run these commands to understand the project before making any recommendations: What to determine: Question Impact build.gradle.kts present? Use Kotlin DSL syntax in all examples gradle/libs.versions.toml present? Add Sentry to the version catalog; reference via libs. in build files Catalog already has sentry entries? Reuse the existing version ref; don't duplicate or hardcode versions minSdk < 26 ? Note Session Replay requires API 26+ — silent no op below that Compose detected? Recommend sentry compose android and Compose specific masking OkHttp present? Recommend sentry okhttp interceptor or Gradle plugin bytecode auto instrumentation Room/SQLite present? Recommend sentry android sqlite or plugin bytecode instrumentation Timber present? Recommend sentry android timber integration Jetpack Navigation? Recommend sentry android navigation for screen tracking Already has SentryAndroid.init() ? Skip install, jump to feature config Application subclass exists? That's where SentryAndroid.init() goes Phase 2: Recommend Present a concrete recommendation based on what you found. Don't ask open ended questions — lead with a proposal: Recommended (core coverage — always set up these): ✅ Error Monitoring — captures uncaught exceptions, ANRs, and native NDK crashes automatically ✅ Tracing — auto instruments Activity lifecycle, app start, HTTP requests, and database queries ✅ Session Replay — records screen captures and user interactions for debugging (API 26+) Optional (enhanced observability): ⚡ Profiling — continuous UI profiling (recommended) or transaction based sampling ⚡ Logging — structured logs via Sentry.logger() , with optional Timber bridge ⚡ User Feedback — collect user submitted bug reports from inside the app Recommendation logic: Feature Recommend when... Error Monitoring Always — non negotiable baseline for any Android app Tracing Always for Android — app start time, Activity lifecycle, network latency matter Session Replay User facing production app on API 26+; visual debugging of user issues Profiling Performance sensitive apps, startup time investigations, production perf analysis Logging App uses structured logging or you want log to trace correlation in Sentry User Feedback Beta or customer facing app where you want user submitted bug reports Propose: "For your [Kotlin / Java] Android app (minSdk X), I recommend setting up Error Monitoring + Tracing + Session Replay. Want me to also add Profiling and Logging?" Phase 3: Guide Determine Your Setup Path Project type Recommended setup Complexity New project, no existing Sentry Gradle plugin (recommended) Low — plugin handles most config Existing project, no Sentry Gradle plugin or manual init Medium — add dependency + Application class Manual full control SentryAndroid.init() in Application Medium — explicit config, most flexible Option 1: Wizard (Recommended) You need to run this yourself — the wizard opens a browser for login and requires interactive input that the agent can't handle. Copy paste into your terminal: It handles login, org/project selection, Gradle plugin setup, dependency installation, DSN configuration, and ProGuard/R8 mapping upload. Once it finishes, come back and skip to [Verification]( verification). If the user skips the wizard, proceed with Option 2 (Manual Setup) below. Option 2: Manual Setup Using a Gradle Version Catalog ( gradle/libs.versions.toml ) If Phase 1 detected gradle/libs.versions.toml , add Sentry to the catalog first , then reference it from your build files. This keeps versions centralized and matches modern AGP project conventions. Step 1 — Add entries to gradle/libs.versions.toml Note: Optional integration entries omit version.ref — their versions come from the BOM at resolution time. Only sentry bom needs the version ref. If the catalog already defines a sentry version, reuse it instead of adding a duplicate entry. Step 2 — Reference the catalog from build.gradle[.kts] Project level build.gradle.kts : App level app/build.gradle.kts : Groovy DSL ( app/build.gradle ) equivalent: Then continue with the sentry {} configuration block from Path A, Step 2 below. The rest of the setup (Application class init, manifest registration, verification) is identical. Path A: Gradle Plugin (Recommended) The Sentry Gradle plugin is the easiest setup path. It: Uploads ProGuard/R8 mapping files automatically on release builds Injects source context into stack frames Optionally instruments OkHttp, Room/SQLite, File I/O, Compose navigation, and android.util.Log via bytecode transforms (zero source changes) Step 1 — Add the plugin to build.gradle[.kts] (project level) Groovy DSL ( build.gradle ): Kotlin DSL ( build.gradle.kts ): Step 2 — Apply plugin + add dependencies in app/build.gradle[.kts] Groovy DSL: Kotlin DSL ( app/build.gradle.kts ): Step 3 — Initialize Sentry in your Application class If you don't have an Application subclass, create one: Java equivalent: Step 4 — Register Application in AndroidManifest.xml Path B: Manual Setup (No Gradle Plugin) Use this if you can't use the Gradle plugin (e.g., non standard build setups). Step 1 — Add dependency in app/build.gradle[.kts] Step 2 — Initialize in Application class (same as Path A, Step 3) Step 3 — Configure ProGuard/R8 manually The Sentry SDK ships a ProGuard rules file automatically. For manual mapping upload, install sentry cli and add to your CI: Quick Reference: Full Featured SentryAndroid.init() For Each Agreed Feature Walk through features one at a time. Load the reference file for each, follow its steps, then verify before moving on: Feature Reference Load when... Error Monitoring ${SKILL ROOT}/references/error monitoring.md Always (baseline) Tracing & Performance ${SKILL ROOT}/references/tracing.md Always for Android (Activity lifecycle, network) Profiling ${SKILL ROOT}/references/profiling.md Performance sensitive production apps Session Replay ${SKILL ROOT}/references/session replay.md User facing apps (API 26+) Logging ${SKILL ROOT}/references/logging.md Structured logging / log to trace correlation Metrics ${SKILL ROOT}/references/metrics.md Custom metric tracking (SDK ≥ 8.30.0) Crons ${SKILL ROOT}/references/crons.md Scheduled jobs, WorkManager check ins Integration Reference ${SKILL ROOT}/references/integrations.md Built in, optional, and Gradle bytecode integrations For each feature: Read ${SKILL ROOT}/references/<feature .md , follow steps exactly, verify it works. Configuration Reference Core SentryOptions (via SentryAndroid.init ) Option Type Default Purpose dsn String — Required. Project DSN; SDK silently disabled if empty environment String — e.g., "production" , "staging" . Env: SENTRY ENVIRONMENT release String — App version, e.g., "my app@1.0.0+42" . Env: SENTRY RELEASE dist String — Build variant / distribution identifier sendDefaultPii Boolean false Include PII: IP address, user data sampleRate Double 1.0 Error event sampling (0.0–1.0) maxBreadcrumbs Int 100 Max breadcrumbs per event isAttachStacktrace Boolean true Auto attach stack traces to message events isAttachScreenshot Boolean false Capture screenshot on error isAttachViewHierarchy Boolean false Attach JSON view hierarchy as attachment isDebug Boolean false Verbose SDK output. Never use in production isEnabled Boolean true Disable SDK entirely (e.g., for testing) beforeSend SentryOptions.BeforeSendCallback — Modify or drop error events before sending beforeBreadcrumb SentryOptions.BeforeBreadcrumbCallback — Filter breadcrumbs before storage Tracing Options Option Type Default Purpose tracesSampleRate Double 0.0 Transaction sample rate (0–1). Use 1.0 in dev tracesSampler TracesSamplerCallback — Per transaction sampling; overrides tracesSampleRate tracePropagationTargets List<String [". "] Hosts/URLs to receive sentry trace and baggage headers isEnableAutoActivityLifecycleTracing Boolean true Auto instrument Activity lifecycle isEnableTimeToFullDisplayTracing Boolean false TTFD spans (requires Sentry.reportFullyDisplayed() ) isEnableUserInteractionTracing Boolean false Auto instrument user gestures as transactions Profiling Options Option Type Default Purpose profileSessionSampleRate Double 0.0 Continuous profiling sample rate (SDK ≥ 8.7.0, API 22+) profilesSampleRate Double 0.0 Legacy transaction profiling rate (mutually exclusive with continuous) isProfilingStartOnAppStart Boolean false Auto start profiling session on app launch ANR Options Option Type Default Purpose isAnrEnabled Boolean true Enable ANR watchdog thread anrTimeoutIntervalMillis Long 5000 Milliseconds before reporting ANR isAnrReportInDebug Boolean false Report ANRs in debug builds (noisy in debugger) NDK Options Option Type Default Purpose isEnableNdk Boolean true Enable native crash capture via sentry native isEnableScopeSync Boolean true Sync Java scope (user, tags) to NDK layer isEnableTombstoneFetchJob Boolean true Fetch NDK tombstone files for enrichment Session Replay Options ( options.sessionReplay ) Option Type Default Purpose sessionSampleRate Double 0.0 Fraction of all sessions to record onErrorSampleRate Double 0.0 Fraction of error sessions to record maskAllText Boolean true Mask all text in replays maskAllImages Boolean true Mask all images in replays quality SentryReplayQuality MEDIUM Video quality: LOW , MEDIUM , HIGH Logging Options ( options.logs ) Option Type Default Purpose isEnabled Boolean false Enable Sentry.logger() API (SDK ≥ 8.12.0) setBeforeSend BeforeSendLogCallback — Filter/modify log entries before sending Environment Variables Variable Purpose Notes SENTRY DSN Data Source Name Set in CI; SDK reads from environment at init SENTRY AUTH TOKEN Upload ProGuard mappings and source context Never commit — use CI/CD secre