Reputation: 2646
I'm writing a Java alarm clock app for an Android tablet. When I am writing the code and the tablet is connected to my computer, I can easily see the debugging errors and the logcat. But sometimes it crashes when it is just sitting on my table next to my bed (not connected to my computer). No idea when it crashed. How can I find out what caused it long after the fact? The app is not deployed to the app store. It's just a project I am working on (there are plenty of alarm clock app in the app store!). Is there a way for me to capture the stack trace and most recent log entries just before the crash?
Upvotes: 2
Views: 338
Reputation: 311
Certainly! You can use Thread.setDefaultUncaughtExceptionHandler()
On your UI Thread, and use the handler to print the stack trace to a log file, which you can then review on your debugging environment.
Upvotes: 1
Reputation: 6263
This is what Firebase Crashlytics is meant for.
Hook your app up to Firebase crashlytics and you'll be able to see crash reports anytime the app crashes on any device. The advantage of this is that the device does not have to be connected to your computer. Also, you can use crashlytics to monitor/log crashes on both live (Playstore) and non-live apps.
This is a guide on setting up Crashlytics on your Android application.
Upvotes: 2