简体   繁体   English

如何识别为什么Android应用程序崩溃

[英]How to identify why android app crashed

When I are using Java we put System.out.println() for identifying errors, where it went wrong. 当我使用Java我们将System.out.println()识别出错误,并指出错误所在。

A very naive method. 一个非常幼稚的方法。

With android, I cannot even use this method to isolate why the app crashed. 使用android,我什至无法使用此方法来找出应用崩溃的原因。

With Rails we would read the log file. 使用Rails我们将读取日志文件。

But as I am new to Java and android , I don't know which is the best practice. 但是由于我是Javaandroid新手,所以我不知道这是最佳实践。

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. 我相信有一个最佳做法,但我不知道这是什么,而且我无法向Google提出良好的查询。

Please help me, error check android. 请帮助我,错误检查android。

use logcat. 使用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. 使用LogCat,您可以在《 Android开发指南》中查找其方法,以查看适合您的方法。 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. 要显示内容,请转到窗口->显示视图->其他...-> LogCat,并注意发生错误的位置。

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 注意:我在用手机,无法为您提供链接,因此查看LogCat的路径可能不是100%,对不起。

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! 您还可以使用ddms查看Log.x(tag,yourString)(其中x是输出的类型,v =详细,d =调试,e =错误等)创建的调试信息。输出不同的颜色,非常有用!

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. 使用logcat,但是如果它“在我的机器上工作”并且在市场上销售,则可以让用户安装“ Log Collector”,然后如果您有愿意帮助解决问题的用户,则让他们通过电子邮件将日志发送给您。 Then you can read your logcat outputh and the exception details in the log they send to you (which is from their phone). 然后,您可以在他们发送给您的日志中(从他们的电话中)读取logcat输出h和异常详细信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM