Reputation: 28345
Even explicitly writing e.printStackTrace() it doesn't print to the console, why?
Upvotes: 4
Views: 4959
Reputation: 405745
printStackTrace()
doesn't print to the console, it prints to the standard error stream. If you want to print to the screen, set your display text to e.getMessage()
or e.getStackTrace()
. (Although I do recommend learning to debug with logcat instead.)
Upvotes: 2
Reputation: 4691
You cannot print to console on Android. You have to use Android Log class. When I have an exception and I want to print it I'm using:
for (StackTraceElement element : exception.getStackTrace())
Log.e("my_tag", element.toString());
or you can try
String stackTrace = Log.getStackTraceString(throwable);
And after that you can print it to Android Log.
Upvotes: 1
Reputation: 7501
use Log.X() where X is the type of error console you want(Log.e, Log.v, Log.d, etc.)
Upvotes: 1
Reputation: 207902
Checkout Logcat
in DDMS perspective it should be there not in the Console tab.
Or use the ddms
command tool to read logcat.
Upvotes: 7