Analyze Stack Trace like a boss!

In this post we’ll talk about amazing feature Analyze Stack Trace available in AndroidStudio IDE.

A stack trace is generated whenever our app crashes because of an error or an exception. Developing a 100% stable Android application is near to impossible. Application might not crash on our real device or emulator, but there’s a big chance that it will crash on other devices (e.g. Samsung).

Due to that fact analyzing stack traces is an essential part of Android developer work.

We receive crashes via crash-reporting tools like HockeyApp or Crashlytics or any other. It’s a normal process and happens after every release.

Crashes in HockeyApp

Is important to react to crashes quickly, analyze/fix them and publish new application version with hot-fixes. Though analyzing crashes or exceptions by having a stack trace in a crash-reporting tool might take too much time.

Most of the stacktraces contain information in which class and at which line of code exception was thrown. Crash - generate OOM

We can navigate to specific line of code in IDE using go to line: Go to line

This will allow us to find out what happened and why exception was thrown and make a fix if needed.

But sometimes is really hard to understand what caused an exception at specific line of code. And switching between browser with crash log and IDE isn’t convenient :disappointed:

Analyze Stack Trace to the rescue!

AndroidStudio, which is based on Intellij Idea, has an amazing feature called Analyze Stack Trace:

Analyze Stack Trace

Analyze Stack Trace dialog has one important configuration: Automatically detect and analyze thread dumps copied to the clipboard outside of IntelliJ IDEA.

Analyze Stack Trace dialog

When we come back from external application (like HockeyApp page with crash logs), the copied stack trace will be automatically detected and opened:

Crash - generate OOM in IDE

Now we can easily navigate as we normally do when crash occurs on emulator or connected device :open_mouth:

Conclusion

AndroidStudio is really powerful IDE and with every update it brings us new goodies which increase our productivity. Knowing majority of them adds +100 to speed.

comments powered by Disqus