How can I get the equivalent of a printStackTrace in android? I know I can log an error, by passing in a tag name and a String to the logging method, but that just gives me a nullpointerexception. If I call e.printStackTrace(), where is this data printed to?
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
If you are using eclipse make sure you have
LogCat
window opended. You can find it underWindow-> Show View-> Other -> Under Android -> LogCat
updated:2014 July
OR if you are using Android Studio you can find it under
Window menu -> Show view -> Logcat
LogCat
is like a console in normal JAVA. Youre.printstacktrace()
would appear in LogCat as well.Firstly, in case you already haven't, you should be wrapping your code in a
try-catch
structure, like this, for example:This pseudocode will show a complete stack trace.
NEWBIE ALERT: Before publishing app, don't forget to "comment out" (using
//
) this and all debugging features that may be used to expose the internals of your code. Anyone who plugs a device running your code with ADB enabled will be able to access LogCat (whereLog
publishes).The data is still printed to the DDMS logs with e.printStackTrace(); You can also use Log.e("Tag", "Description", e); which will print the logs as well. DDMS is located under android-sdk/tools/ddms and logs will be shown in the bottom pane on launch.