---
metadata:
  - name: generator
    content: Diplodoc Platform v5.66.1
alternate:
  - https://appmetrica.yandex.com.tr/docs/en/sdk/android/analytics/android-crash.md
  - https://appmetrica.yandex.com.tr/docs/ru/sdk/android/analytics/android-crash.md
  - https://appmetrica.yandex.com.tr/docs/zh/sdk/android/analytics/android-crash.md
  - href: https://appmetrica.yandex.com.tr/docs/zh/sdk/android/analytics/android-crash.md
    type: text/markdown
    title: Markdown version
  - href: https://appmetrica.yandex.com.tr/docs/zh/llms.txt?revision=r22018908
    rel: describedby
---
> **Documentation Index:** Fetch the complete configuration index at https://appmetrica.yandex.com.tr/docs/zh/llms.txt?revision=r22018908

# 分析崩溃

AppMetrica 不与其他收集和处理应用崩溃的库冲突。 如果使用这些库，请在安装这些库后初始化 AppMetrica。 

AppMetrica SDK 将崩溃报告保存到文件中，并在下次运行时发送。

{% note info "" %}

该库不会对应用崩溃进行符号化或去混淆处理。 这些操作在服务器端或客户端执行。

要将映射文件上传到AppMetrica，请使用[AppMetricaGradle Plugin](https://appmetrica.yandex.com.tr/docs/zh/sdk/android/analytics/android-gradle-plugin.md)。 它在构建应用时会自动上传映射文件和SO文件。 要获取更多信息，请查看[在 Android 上上传映射文件和调试符号](https://appmetrica.yandex.com.tr/docs/zh/data-collection/upload-mapping.md)。

{% endnote %}

为了自动收集应用崩溃的信息，AppMetrica 使用标准处理程序 [Thread.UncaughtExceptionHandler](https://developer.android.com/reference/java/lang/Thread.UncaughtExceptionHandler.html)。 如果您直接在应用中使用应用崩溃处理程序，请使用以下正确处理数据的实现示例：

{% list tabs group=instructions %}

- Kotlin

   ```kotlin translate=no
   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)
   ```

- Java

   ```java translate=no
   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);
   ```

{% endlist %}

这样你可以自己处理异常，然后传递它，AppMetrica 可以发送有关它的信息。

如果您想传输关于应用崩溃的额外信息，请参考此示例，直到[在应用中初始化库](https://appmetrica.yandex.com.tr/docs/zh/sdk/android/analytics/quick-start.md)。

## 了解更多 {#learn-more}

- [AppMetrica Gradle 插件](https://appmetrica.yandex.com.tr/docs/zh/sdk/android/analytics/android-gradle-plugin.md)
- [在 Android 上上传映射文件和调试符号](https://appmetrica.yandex.com.tr/docs/zh/data-collection/upload-mapping.md)

<!-- source: zh/_includes/feedback-button-3.md -->
如果您没有找到所需答案，可以通过反馈表单提交您的问题。 请尽可能详细地描述问题。 如果可能，请附上截图。

<a href="../troubleshooting/feedback-new">
  <span class="button">联系支持</span>
</a>

<a href="../troubleshooting/feedback-docs">
  <span class="button">为文档提出改进建议</span>
</a>
<!-- endsource: zh/_includes/feedback-button-3.md -->
