0

我的 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)
4

1 回答 1

3

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

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

从这里您可以选择该行(在 Eclipse 中),Eclipse 将带您直接找到代码中的问题行。现在回头看看你的日志猫的顶部,你会看到你有一个空指针异常。如果您无法立即检测到问题所在,您可以在该行代码上设置断点并调试您的代码。一旦你到达那个断点,查看该行上的每个项目并找到空值。

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

我希望这有帮助。

于 2013-07-16T19:50:53.843 回答