How to identify why android app crashed
When I are using Java
we put System.out.println()
for identifying errors, where it went wrong.
A very naive method.
With android, I cannot even use this method to isolate why the app crashed.
With Rails
we 开发者_高级运维would read the log file.
But as I am new to Java
and android
, I don't know which is the best practice.
I believe there is a best practice, but I don't know what it is, and I couldn't formulate a good query to google around.
Please help me, error check android.
use logcat.
For more information on how to debug refer this tutorial
Use LogCat, you can lookup its method on the Android Dev Guide to see which one works for you. I chose verbose so my debug statements look like
Log.v("MyAppName", "Inside my function now, its so dark");
To show the content go to Window -> Show Views -> Other... -> LogCat and watch for where your errors occur.
NOTE: I am on my phone and could not provide the link for you and the path to view LogCat may not be 100%, my apologizes
You can also view the debug info created by Log.x(tag, yourString) (where x is the type of output, v = verbose, d = debug, e = error etc) using ddms, which will also highlight the different types of output differnt colors, very useful!
Dori
Use logcat, but if it "Works on My Machine" and its on the marketplace you can have users install "Log Collector" and then have them email you the log if you have a user who is willing to help troubleshoot the problem. Then you can read your logcat outputh and the exception details in the log they send to you (which is from their phone).
精彩评论