如何解读Logcat [英] How to interpret Logcat

查看:39
本文介绍了如何解读Logcat的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁能告诉我应该如何阅读 Logcat 中的错误?我想了解我的问题在哪里.

Can anyone tell me how I should read the errors in Logcat? I'd like to understand where my problem is.

目前,我试图阅读它,但找不到崩溃的原因.

At the moment, I tried to read it but can't find the cause of the crash.

这是我不明白的 Logcat:

Here's the Logcat I don't understand:

05-18 18:29:44.160: ERROR/AndroidRuntime(2145): FATAL EXCEPTION: main
05-18 18:29:44.160: ERROR/AndroidRuntime(2145): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.paad.whereami/com.paad.whereami.WhereAmI}: java.lang.NullPointerException
05-18 18:29:44.160: ERROR/AndroidRuntime(2145):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
05-18 18:29:44.160: ERROR/AndroidRuntime(2145):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
05-18 18:29:44.160: ERROR/AndroidRuntime(2145):     at android.app.ActivityThread.access$1500(ActivityThread.java:117)
05-18 18:29:44.160: ERROR/AndroidRuntime(2145):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
05-18 18:29:44.160: ERROR/AndroidRuntime(2145):     at android.os.Handler.dispatchMessage(Handler.java:99)
05-18 18:29:44.160: ERROR/AndroidRuntime(2145):     at android.os.Looper.loop(Looper.java:130)
05-18 18:29:44.160: ERROR/AndroidRuntime(2145):     at android.app.ActivityThread.main(ActivityThread.java:3683)
05-18 18:29:44.160: ERROR/AndroidRuntime(2145):     at java.lang.reflect.Method.invokeNative(Native Method)
05-18 18:29:44.160: ERROR/AndroidRuntime(2145):     at java.lang.reflect.Method.invoke(Method.java:507)
05-18 18:29:44.160: ERROR/AndroidRuntime(2145):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
05-18 18:29:44.160: ERROR/AndroidRuntime(2145):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
05-18 18:29:44.160: ERROR/AndroidRuntime(2145):     at dalvik.system.NativeStart.main(Native Method)
05-18 18:29:44.160: ERROR/AndroidRuntime(2145): Caused by: java.lang.NullPointerException
05-18 18:29:44.160: ERROR/AndroidRuntime(2145):     at com.paad.whereami.WhereAmI.updateWithNewLocation(WhereAmI.java:290)
05-18 18:29:44.160: ERROR/AndroidRuntime(2145):     at com.paad.whereami.WhereAmI.onCreate(WhereAmI.java:216)
05-18 18:29:44.160: ERROR/AndroidRuntime(2145):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
05-18 18:29:44.160: ERROR/AndroidRuntime(2145):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)

推荐答案

在这种情况下,您的日志的第二个部分"将对您很重要.

The second "part" of your log is going to be what is important for you in this instance.

原因:java.lang.NullPointerException

这意味着在您的代码中某处设置了 null 而您正试图使用​​它,好像它不是.

This means that somewhere in your code something is set to null and you are trying to use it as though it isn't.

接下来的几行告诉您可以在代码中的哪个位置找到错误.

The next few lines tell you where in your code you can find the error.

在 com.paad.whereami.WhereAmI.updateWithNewLocation(WhereAmI.java:290)
at com.paad.whereami.WhereAmI.onCreate(WhereAmI.java:216)

这应该意味着您有一个名为 updateWithNewLocation 的方法,您正在第 216 行从 onCreate 调用该方法.错误来自第 290 行的此方法内部.以查看代码中的第 290 行.您在该行上尝试执行的任何操作都会导致异常,因为某些内容不应该是 null.

This should mean that you have a method named updateWithNewLocation that you are calling from onCreate at line 216. The error is coming from inside this method at line 290. Take a look at line 290 in your code. Whatever you are trying to do on that line is causing the exception because something is null that shouldn't be.

这篇关于如何解读Logcat的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆