Mobile SDK

Error monitoring for Android

A Kotlin SDK that installs an uncaught-exception handler in `Application.onCreate()`. Device metadata is caller-supplied, so the library ships no platform-specific dependencies.

Frameworks AndroidRequires Android API 24+ · JDK 17 to buildPackage com.errorgap:errorgap-androidSource ↗Package ↗Agent guide ↗
Install

Install

kotlin
dependencies {
    implementation("com.errorgap:errorgap-android:0.2.0")
}
Configure

Configure

In Application.onCreate(), before anything else runs:

kotlin
class App : Application() {
    override fun onCreate() {
        super.onCreate()
        Errorgap.init(ErrorgapConfiguration(
            endpoint = BuildConfig.ERRORGAP_ENDPOINT,
            projectSlug = BuildConfig.ERRORGAP_PROJECT_SLUG,
            apiKey = BuildConfig.ERRORGAP_API_KEY,
            environment = if (BuildConfig.DEBUG) "development" else "production",
            release = BuildConfig.VERSION_NAME,
            deviceInfo = mapOf(
                "os_name" to "Android",
                "os_version" to Build.VERSION.RELEASE,
                "device_model" to Build.MODEL,
                "app_version" to BuildConfig.VERSION_NAME,
            ),
        ))
    }
}

Expose the credentials through BuildConfig fields (from Gradle properties or the environment) rather than hardcoding them. The SDK installs a Thread.setDefaultUncaughtExceptionHandler.

Session replay

Session replay

Version 0.5.0 records session replay when running on Android. Mobile sessions are a timeline only — app start, screens, failed API calls, errors and backgrounding — with no screenshots. Whether anything is recorded is set per project in Errorgap under Settings → Session replay: nothing while replay is off, and a sampled share of sessions while it is on. Only sessions that hit an error are kept, and each opens from its error group or incident.

The library doesn't depend on the Android SDK, so call Errorgap.trackScreen(name) and Errorgap.appPaused() / appResumed() from ActivityLifecycleCallbacks, and Errorgap.recordCall(...) from an OkHttp interceptor — the README has the full snippet.

Trigger a test error

Trigger a test error

kotlin
button.setOnClickListener {
    throw RuntimeException("Errorgap test error")
}
Verify

Verify the connection

Confirm your key and endpoint reach errorgap before wiring anything else — send one event straight to the ingestion API:

bash
curl -sS -X POST "$ERRORGAP_ENDPOINT/api/projects/$ERRORGAP_PROJECT_SLUG/notices" \
  -H "content-type: application/json" \
  -H "x-errorgap-project-key: $ERRORGAP_API_KEY" \
  -d '{"errors":[{"type":"ErrorgapInstallTest","message":"Errorgap install verification"}]}'

A 201 with a group_id means ingestion works (202 = received but sampled; 401 = wrong key). Then trigger the test error above through the SDK. Your onboarding screen's Verify step checks the stack off automatically once the first event lands — it polls every three seconds.

Next: the full ingestion API, or browse every SDK.