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.

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.