Skip to content

Most visited

Recently visited


Analyze a Stack Trace

Debugging an app often requires working with stack traces. A stack trace is generated whenever your app crashes because of an error or an exception. You can also print a stack trace at any point in your app code using methods such as Thread.dumpStack().

While your app is running in debug mode on a connected device, Android Studio prints and highlights stack traces in the logcat view, as shown in figure 1.

Figure 1. A stacktrace in logcat.

A stack trace shows a list of method calls that lead to the exception being thrown, together with the filenames and line numbers where the calls happened. You can click on the highlighted filenames to open the files and examine the source of the method invocation. Click Up the stack trace and Down the stack trace to quickly move between stack trace lines displayed in the logcat window.

Open Stack Traces from External Sources

Sometimes you want to analyze stack traces that were shared with you in a bug report as opposed to those you found while debugging. For example, you might be collecting stack traces generated on your users’ devices from the Google Play Console or from some other tool such as Firebase Crash Reporting.

To get the same highlighted and clickable view of an external stack trace from a bug report, follow these steps:

  1. Open your project in Android Studio.

    Note: Make sure the source code you're viewing is from the exact same version of your app which generated the stack trace. If the code is different, you will get mismatches between the filenames and line numbers, or the order of calls in the stack trace and your project.

  2. From the Analyze menu, click Analyze stacktrace.

    Analyze Stacktrace window

  3. Paste the stack trace text into the Analyze Stacktrace window and click OK.
  4. Android Studio opens a new <Stacktrace> tab with the stack trace you pasted under the Run window.

    Stacktrace window

Monitor the Clipboard for New Stacktraces

If you work with external stack traces a lot, you can improve your productivity by allowing Android Studio to continuously monitor the system clipboard for new stacktraces:

  1. Open the Analyze Stacktrace tool.
  2. Check the Automatically detect and analyze thread dumps copied to the clipboard outside of IntelliJ IDEA checkbox.
  3. Copy a stack trace in another application (such as from a web browser) to the system clipboard.
  4. When you come back to the Android Studio window, the stack trace opens automatically under the Run window, without you having to paste it in the Analyze Stacktrace window.
This site uses cookies to store your preferences for site-specific language and display options.

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields


Follow Google Developers on WeChat

Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a short survey?
Help us improve the Android developer experience. (Dec 2017 Android Platform & Tools Survey)