AppAmbit Crashes Android
AppAmbit Crashes automatically records a crash log whenever your application crashes. Initially, the log is saved to the device’s local storage. Once the app is reopened, the crash report is sent to AppAmbit, offering valuable insights to help diagnose and fix issues.
Generate a Test Crash
To simplify SDK testing, AppAmbit Crashes provides an API for generating a test crash.
Java
Crashes.generateTestCrash();
Kotlin
Crashes.generateTestCrash()
Handled Errors
AppAmbit also supports tracking non-fatal errors by logging handled exceptions:
Java
try {
...
} catch (Exception exception) {
Crashes.logError(exception);
}
Kotlin
try {
...
} catch (exception: Exception) {
Crashes.logError(exception)
}
Besides, an application can attach properties to a controlled error report to provide more context. Pass the properties as a map of key-value pairs (strings only) as shown in the following example.
Java
try {
...
} catch (Exception exception) {
Map<String, String> properties = new HashMap<>();
properties.put("user_id", "1");
Crashes.logError(exception, properties);
}
Kotlin
try {
...
} catch (exception : Exception) {
val properties: Map<String, String> = mapOf(
"user_id" to "1"
)
Crashes.logError(exception, properties);
}
Additionally, you can log custom error messages for better visibility during unexpected situations:
Java
try {
...
} catch (Exception exception) {
String message = "Error NullPointerException"
Crashes.logError(message);
}
Kotlin
try {
...
} catch (exception: Exception) {
val message = "Error NullPointerException"
Crashes.logError(message);
}
Even log with message and properties and use it to get details about errors
Java
try {
...
} catch (Exception exception) {
Map<String, String> properties = new HashMap<>();
properties.put("user_id", "1");
String message = "Error NullPointerException"
Crashes.logError(message, properties);
}
Kotlin
try {
...
} catch (exception : Exception) {
val properties: Map<String, String> = mapOf(
"user_id" to "1"
)
val message = "Error NullPointerException"
Crashes.logError(message, properties);
}
Details about the last crash
If the app has previously crashed, the function will return a boolean
Java
Crashes.didCrashInLastSession()
Kotlin
Crashes.didCrashInLastSession()