Analyzing crashes
AppMetrica doesn't conflict with other libraries that collect and process app crashes. If you use such libraries, initialize AppMetrica after installing these libraries.
Note
The library does not symbolicate or deobfuscate app crashes. These operations are performed on the server or on the client side.
To upload mapping files to AppMetrica, use the crash plugin. It automatically uploads the mapping and SO files when building an app. For more information, see uploading mapping files and debugging symbols on Android.
For automatically collecting information about app crashes, AppMetrica uses the standard handler Thread.UncaughtExceptionHandler. If you are using an app crash handler directly inside the app, use the following example of implementing correct data handling:
val previousUncaughtExceptionHandler = Thread.getDefaultUncaughtExceptionHandler()
// Creating a new handler.
val uncaughtExceptionHandler = Thread.UncaughtExceptionHandler { thread, exception ->
try {
// Put your logic here.
} finally {
// Sending a message about an app crash to the system handler.
previousUncaughtExceptionHandler?.uncaughtException(thread, exception)
}
}
// Setting the default handler.
Thread.setDefaultUncaughtExceptionHandler(uncaughtExceptionHandler)
final Thread.UncaughtExceptionHandler previousUncaughtExceptionHandler = Thread.getDefaultUncaughtExceptionHandler();
// Creating a new handler.
Thread.UncaughtExceptionHandler uncaughtExceptionHandler = new Thread.UncaughtExceptionHandler() {
@Override
public void uncaughtException(@NotNull Thread thread, @NotNull Throwable exception) {
try {
// Put your logic here.
} finally {
// Sending a message about an app crash to the system handler.
if (previousUncaughtExceptionHandler != null) {
previousUncaughtExceptionHandler.uncaughtException(thread, exception);
}
}
}
};
// Setting the default handler.
Thread.setDefaultUncaughtExceptionHandler(uncaughtExceptionHandler);
This way you handle the exception yourself, then pass it on, and AppMetrica can send information about it.
If you want to transmit additional information about an app crash, use this example up to initializing the library in the app.
Learn more
If you didn't find the answer you were looking for, you can use the feedback form to submit your question. Please describe the problem in as much detail as possible. Attach a screenshot if possible.