Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where do I see printed stack trace in Android Studio?

I'm new to Android Studio and Java programming. I have the following draft code:

    try {
        InetAddress serverAddr = InetAddress.getByName("whatever");
        Socket socket = new Socket(serverAddr, 5555);
    } catch (UnknownHostException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

Socket throws exception of type IOException, so e.printStackTrace() will be called. While running this under debugger, I cannot find a place/window in Android Studio where this stack trace is printed. I guess this must be printed in Android Studio's Console window, but there is nothing printed in there. Android Studio 1.3.2, default settings. So where is this stack trace printed?

Thanks in advance!

like image 727
Sergey Avatar asked Aug 29 '15 08:08

Sergey


People also ask

Where is the stack trace in Android Studio?

From the Analyze menu, click Analyze Stack Trace. Paste the stack trace text into the Analyze Stack Trace window and click OK. Android Studio opens a new <Stacktrace> tab with the stack trace you pasted under the Run window.

How do I view stack trace?

To open the Call Stack window in Visual Studio, from the Debug menu, choose Windows>Call Stack. To set the local context to a particular row in the stack trace display, select and hold (or double click) the first column of the row.

How do I print current stack trace?

The printStackTrace() method of Java. lang. Throwable class used to print this Throwable along with other details like class name and line number where the exception occurred means its backtrace. This method prints a stack trace for this Throwable object on the standard error output stream.


1 Answers

Stack trace will be send to default (console) output. In Android Studio (which is based on IntelliJ idea) is that window called logcat.

@See image below. enter image description here

If you can not see this tab, go to Window > and click Restore Default Layout You can click Shift + F12 as well.

like image 140
Daniel Perník Avatar answered Oct 19 '22 14:10

Daniel Perník