如何阅读Android LogCat - Android

时间:2013-07-16 19:45:25

标签: android-logcat

我的Logcat中有一个错误导致我的应用程序崩溃,但我不知道如何判断错误在哪一行或错误到底是什么,这是我的LogCat希望有人可以告诉我这是什么问题

    07-16 15:37:49.255: E/AndroidRuntime(21545): FATAL EXCEPTION: main
07-16 15:37:49.255: E/AndroidRuntime(21545): java.lang.NullPointerException
07-16 15:37:49.255: E/AndroidRuntime(21545):    at android.widget.ListView.measureScrapChild(ListView.java:1163)
07-16 15:37:49.255: E/AndroidRuntime(21545):    at android.widget.ListView.measureHeightOfChildren(ListView.java:1294)
07-16 15:37:49.255: E/AndroidRuntime(21545):    at android.widget.ListView.onMeasure(ListView.java:1155)
07-16 15:37:49.255: E/AndroidRuntime(21545):    at android.view.View.measure(View.java:13011)
07-16 15:37:49.255: E/AndroidRuntime(21545):    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4706)
07-16 15:37:49.255: E/AndroidRuntime(21545):    at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1369)
07-16 15:37:49.255: E/AndroidRuntime(21545):    at android.widget.LinearLayout.measureVertical(LinearLayout.java:660)
07-16 15:37:49.255: E/AndroidRuntime(21545):    at android.widget.LinearLayout.onMeasure(LinearLayout.java:553)
07-16 15:37:49.255: E/AndroidRuntime(21545):    at android.view.View.measure(View.java:13011)
07-16 15:37:49.255: E/AndroidRuntime(21545):    at android.widget.RelativeLayout.measureChild(RelativeLayout.java:579)
07-16 15:37:49.255: E/AndroidRuntime(21545):    at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:392)
07-16 15:37:49.255: E/AndroidRuntime(21545):    at android.view.View.measure(View.java:13011)
07-16 15:37:49.255: E/AndroidRuntime(21545):    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4706)
07-16 15:37:49.255: E/AndroidRuntime(21545):    at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1369)
07-16 15:37:49.255: E/AndroidRuntime(21545):    at android.widget.LinearLayout.measureHorizontal(LinearLayout.java:1017)
07-16 15:37:49.255: E/AndroidRuntime(21545):    at android.widget.LinearLayout.onMeasure(LinearLayout.java:555)
07-16 15:37:49.255: E/AndroidRuntime(21545):    at android.view.View.measure(View.java:13011)
07-16 15:37:49.255: E/AndroidRuntime(21545):    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4706)
07-16 15:37:49.255: E/AndroidRuntime(21545):    at android.widget.FrameLayout.onMeasure(FrameLayout.java:293)
07-16 15:37:49.255: E/AndroidRuntime(21545):    at android.view.View.measure(View.java:13011)
07-16 15:37:49.255: E/AndroidRuntime(21545):    at android.widget.LinearLayout.measureVertical(LinearLayout.java:812)
07-16 15:37:49.255: E/AndroidRuntime(21545):    at android.widget.LinearLayout.onMeasure(LinearLayout.java:553)
07-16 15:37:49.255: E/AndroidRuntime(21545):    at android.view.View.measure(View.java:13011)
07-16 15:37:49.255: E/AndroidRuntime(21545):    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4706)
07-16 15:37:49.255: E/AndroidRuntime(21545):    at android.widget.FrameLayout.onMeasure(FrameLayout.java:293)
07-16 15:37:49.255: E/AndroidRuntime(21545):    at android.view.View.measure(View.java:13011)
07-16 15:37:49.255: E/AndroidRuntime(21545):    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4706)
07-16 15:37:49.255: E/AndroidRuntime(21545):    at android.widget.FrameLayout.onMeasure(FrameLayout.java:293)
07-16 15:37:49.255: E/AndroidRuntime(21545):    at com.navdrawer.SimpleSideDrawer.onMeasure(SimpleSideDrawer.java:443)
07-16 15:37:49.255: E/AndroidRuntime(21545):    at android.view.View.measure(View.java:13011)
07-16 15:37:49.255: E/AndroidRuntime(21545):    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4706)
07-16 15:37:49.255: E/AndroidRuntime(21545):    at android.widget.FrameLayout.onMeasure(FrameLayout.java:293)
07-16 15:37:49.255: E/AndroidRuntime(21545):    at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2162)
07-16 15:37:49.255: E/AndroidRuntime(21545):    at android.view.View.measure(View.java:13011)
07-16 15:37:49.255: E/AndroidRuntime(21545):    at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1091)
07-16 15:37:49.255: E/AndroidRuntime(21545):    at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2505)
07-16 15:37:49.255: E/AndroidRuntime(21545):    at android.os.Handler.dispatchMessage(Handler.java:99)
07-16 15:37:49.255: E/AndroidRuntime(21545):    at android.os.Looper.loop(Looper.java:154)
07-16 15:37:49.255: E/AndroidRuntime(21545):    at android.app.ActivityThread.main(ActivityThread.java:4945)
07-16 15:37:49.255: E/AndroidRuntime(21545):    at java.lang.reflect.Method.invokeNative(Native Method)
07-16 15:37:49.255: E/AndroidRuntime(21545):    at java.lang.reflect.Method.invoke(Method.java:511)
07-16 15:37:49.255: E/AndroidRuntime(21545):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
07-16 15:37:49.255: E/AndroidRuntime(21545):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
07-16 15:37:49.255: E/AndroidRuntime(21545):    at dalvik.system.NativeStart.main(Native Method)

1 个答案:

答案 0 :(得分:3)

我总是从上到下查看日志猫,我正在寻找MYCLASS上的第一行,这是错误发生的最后一个位置。在你的情况下,这将是:

07-16 15:37:49.255: E/AndroidRuntime(21545):    at com.navdrawer.SimpleSideDrawer.onMeasure(SimpleSideDrawer.java:443)

从这里你可以选择那条线(在eclipse中),eclipse会把你带到代码中的问题行。现在回顾一下日志猫的顶部,你会发现你有一个nullpointerexception。如果您无法立即检测到错误,可以在该行代码上设置断点并调试代码。一旦你点击那个断点,看看那一行上的每个项目,找到一些空的东西。

在没有看到您的代码的情况下,我无法帮助您说明在这种情况下什么是null。

我希望这会有所帮助。