Skip to main content
Version: 2.1.x

Crash & Error Reporting in KMP

Appxiom provides real-time detection for fatal crashes, ANRs (Application Not Responding) on Android, app hangs on iOS, uncaught Coroutine errors, and handled non-fatal exceptions in Kotlin Multiplatform applications.


1. Automated Uncaught Crash & ANR Detection​

  • Android: Appxiom attaches an unhandled exception handler to the JVM thread and monitors the main looper for ANRs (freezes exceeding 5 seconds). When a fatal crash or ANR occurs, full thread stack traces, device specs, memory status, and the chronological activity trail leading up to the crash are persisted and synchronized.
  • iOS: Appxiom intercepts Mach kernel exceptions and POSIX signals (SIGSEGV, SIGABRT, SIGBUS, SIGFPE) across Swift, Objective-C, and Kotlin/Native code. It also monitors the main run loop for main thread hangs.

Both Android ANRs and iOS app hangs are tracked automatically once Ax.init (Android) and Ax.startIOS (iOS) are called.


2. Handled Error Reporting (Ax.reportError)​

To report caught exceptions without crashing the user's application, use Ax.reportError:

import tech.appxiom.kmp.Ax

try {
processPayment(order)
} catch (t: Throwable) {
// Non-fatal error report
Ax.reportError(
throwable = t,
fatal = false,
customInfo = "Failed during payment processing for orderId: ${order.id}"
)
}
  • throwable: The caught exception or error instance.
  • fatal: Whether this error should be marked as fatal in dashboard severity filters (defaults to false).
  • customInfo: Optional contextual string containing relevant diagnostic information.

3. Coroutine Exception Handler (Ax.coroutineExceptionHandler)​

Uncaught errors in Kotlin Coroutines running on background dispatchers (Dispatchers.IO, Dispatchers.Default) can fail silently or cancel entire job hierarchies without reaching JVM thread handlers.

Attach Ax.coroutineExceptionHandler to your Coroutine scopes:

import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.SupervisorJob
import tech.appxiom.kmp.Ax

// Application-wide background worker scope
val workerScope = CoroutineScope(
SupervisorJob() + Dispatchers.Default + Ax.coroutineExceptionHandler
)

Any uncaught exception thrown inside coroutines launched from workerScope is reported to the Appxiom dashboard with full stack traces.


4. Custom Issue Reporting (Ax.reportIssue)​

Record domain-specific business exceptions or diagnostic issues:

import tech.appxiom.kmp.Ax

Ax.reportIssue(
where = "AuthenticationService",
description = "Token Refresh Timeout",
detailedDescription = "OAuth2 refresh endpoint failed to respond after 15 seconds. User forced to re-login."
)
  • where: The class, module, or service where the issue originated (e.g. "AuthenticationService").
  • description: Brief summary (max 128 characters). Issues with identical where and description are automatically deduplicated and grouped into a single issue.
  • detailedDescription: Full diagnostic payload, parameters, or debug context.

Next Steps​

Learn how to detect memory leaks in Memory Leak Detection.