1

I am in a situation where I cannot use third party Crash reporting platform (Crashalytics ...etc)

So, I started to use self developed Rest API to receive crash reports from mobile app.

However, I can only send handled crashes so far by using try-catch

How can I handle all crashes thrown by my mobile app even those which are not in my try-catch clauses

Just like Crashlytics which can catch all crashes and sends them to Firebase without placing try-catch

malhobayyeb
  • 2,725
  • 11
  • 57
  • 91
  • For that you need to create a custom class which can report whenever any crash happens in the whole application – Karan Mehta Jan 27 '20 at 07:34

2 Answers2

1

There is a library which you can use called 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 {
Manohar
  • 22,116
  • 9
  • 108
  • 144
1

Have a look at Thread.UncaughtExceptionHandler

from the docs :

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.

using this, you can get all threads and all exceptions, which you can then report to any API you'd like

you can find examples of how it was implemented here and here

a_local_nobody
  • 7,947
  • 5
  • 29
  • 51