Log exceptions in a native Android app
The Connect library can capture exception data from your Android app and send it to the Connect collector.
Automatic exception logging
The SDK automatically captures uncaught exceptions — crashes that terminate the app. When an uncaught exception occurs, the library records the stack trace and the state of the device and sends it to the Connect collector. No additional setup is required.
Manual exception logging
For caught exceptions, call Connect.logException() in your catch block. This gives you the same stack trace and device information as an uncaught exception, without terminating the app.
Basic example
Use the single-parameter overload for the simplest case:
try {
val array = IntArray(1)
val i = array[2] // throws IndexOutOfBoundsException
} catch (e: Exception) {
Connect.logException(e)
}With additional data
Pass a HashMap to attach context to the exception — for example, the current user action or screen state:
try {
val array = IntArray(1)
val i = array[2]
} catch (e: Exception) {
val data = HashMap<String, String>()
data["screen"] = "CheckoutFragment"
data["action"] = "submitOrder"
Connect.logException(e, data)
}Mark as unhandled
If you are catching an exception that would normally be unhandled — for example, in a global error boundary — pass unhandled = true so Connect treats it as a crash:
Connect.logException(e, data, unhandled = true)API reference
For the full logException signature, see Connect Android SDK: event and data logging.
Updated 2 days ago
