My application is being executed in debug mode and then deadlock happens. Is there any way to see the stacktrace before deadlock or at least the last called method?
You can obtain a stack trace from a thread – by calling the getStackTrace method on that Thread instance. This invocation returns an array of StackTraceElement, from which details about stack frames of the thread can be extracted.
This might be the easiest way to add the Stacktrace option in Android Studio, simply navigate to the files option and then you can add Stacktrace in place of command-line options and you are good to go.
In the previous java versions, we can use Throwable::getStackTrace, Thread::getStackTrace, and SecurityManager:: GetClassContext provided methods to obtain the thread stack. Thread. getStackTrace() method will return an array of stack trace elements representing the stack dump of a thread (StackTraceElement[]).
A stack trace shows the call stack (sets of active stack frames) and provides information on the methods that your code called. Usually, a stack trace is shown when an Exception is not handled correctly in code. (An exception is what a runtime environment uses to tell you that there's an error in your code.)
Click BreakAll (Ctrl + Alt + Break) and open Debug->Windows->Threads
There you can see stacktrace for every thread
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With