将所有 Android 次崩溃报告给自己 API
Report all Android crashes to own API
我处于无法使用第三方崩溃报告平台(Crashalytics ...等)的情况
所以,我开始使用自己开发的 Rest API 来接收来自移动应用程序的崩溃报告。
但是,到目前为止,我只能使用 try-catch
发送已处理的崩溃
我如何处理我的移动应用抛出的所有崩溃,即使那些不在我的 try-catch
条款中的崩溃
就像 Crashlytics 一样,它可以捕获所有崩溃并将它们发送到 Firebase 而无需放置 try-catch
有一个库可以使用 ACRA , its an open source library you can check its code , or you can directly use their library and configure it to hit your api
@AcraHttpSender(uri = "http://yourserver.com/yourscript",
basicAuthLogin = "yourlogin", // optional
basicAuthPassword = "y0uRpa$$w0rd", // optional
httpMethod = HttpSender.Method.POST)
public class MyApplication extends Application {
看看Thread.UncaughtExceptionHandler
来自文档:
When a thread is about to terminate due to an uncaught exception the
Java Virtual Machine will query the thread for its
UncaughtExceptionHandler using Thread.getUncaughtExceptionHandler()
and will invoke the handler's uncaughtException method, passing the
thread and the exception as arguments. If a thread has not had its
UncaughtExceptionHandler explicitly set, then its ThreadGroup object
acts as its UncaughtExceptionHandler. If the ThreadGroup object has no
special requirements for dealing with the exception, it can forward
the invocation to the default uncaught exception handler.
使用它,您可以获得所有线程和所有异常,然后您可以将其报告给您想要的任何 API
你可以找到它是如何实现的例子
and here
我处于无法使用第三方崩溃报告平台(Crashalytics ...等)的情况
所以,我开始使用自己开发的 Rest API 来接收来自移动应用程序的崩溃报告。
但是,到目前为止,我只能使用 try-catch
我如何处理我的移动应用抛出的所有崩溃,即使那些不在我的 try-catch
条款中的崩溃
就像 Crashlytics 一样,它可以捕获所有崩溃并将它们发送到 Firebase 而无需放置 try-catch
有一个库可以使用 ACRA , its an open source library you can check its code , or you can directly use their library and configure it to hit your api
@AcraHttpSender(uri = "http://yourserver.com/yourscript",
basicAuthLogin = "yourlogin", // optional
basicAuthPassword = "y0uRpa$$w0rd", // optional
httpMethod = HttpSender.Method.POST)
public class MyApplication extends Application {
看看Thread.UncaughtExceptionHandler
来自文档:
When a thread is about to terminate due to an uncaught exception the Java Virtual Machine will query the thread for its UncaughtExceptionHandler using Thread.getUncaughtExceptionHandler() and will invoke the handler's uncaughtException method, passing the thread and the exception as arguments. If a thread has not had its UncaughtExceptionHandler explicitly set, then its ThreadGroup object acts as its UncaughtExceptionHandler. If the ThreadGroup object has no special requirements for dealing with the exception, it can forward the invocation to the default uncaught exception handler.
使用它,您可以获得所有线程和所有异常,然后您可以将其报告给您想要的任何 API
你可以找到它是如何实现的例子