1

我正在 Eclipce 中为 android 编写程序。
我遇到了错误调试问题,当错误发生时,例如NullPointerExceptioin我可以看到,记录双击(在日志上)不起作用?据我所知,它应该向我显示代码中发生异常的行。有人知道如何解决这个问题吗?



10-27 20:28:41.202: E/AndroidRuntime(3232): FATAL EXCEPTION: main
10-27 20:28:41.202: E/AndroidRuntime(3232): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.bignerdranch.andriod.geoquiz/com.bignerdranch.andriod.geoquiz.QuizActivity}: java.lang.NullPointerException
10-27 20:28:41.202: E/AndroidRuntime(3232):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
10-27 20:28:41.202: E/AndroidRuntime(3232):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
10-27 20:28:41.202: E/AndroidRuntime(3232):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
10-27 20:28:41.202: E/AndroidRuntime(3232):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
10-27 20:28:41.202: E/AndroidRuntime(3232):     at android.os.Handler.dispatchMessage(Handler.java:99)
10-27 20:28:41.202: E/AndroidRuntime(3232):     at android.os.Looper.loop(Looper.java:137)
10-27 20:28:41.202: E/AndroidRuntime(3232):     at android.app.ActivityThread.main(ActivityThread.java:5039)
10-27 20:28:41.202: E/AndroidRuntime(3232):     at java.lang.reflect.Method.invokeNative(Native Method)
10-27 20:28:41.202: E/AndroidRuntime(3232):     at java.lang.reflect.Method.invoke(Method.java:511)
10-27 20:28:41.202: E/AndroidRuntime(3232):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
10-27 20:28:41.202: E/AndroidRuntime(3232):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
10-27 20:28:41.202: E/AndroidRuntime(3232):     at dalvik.system.NativeStart.main(Native Method)
10-27 20:28:41.202: E/AndroidRuntime(3232): Caused by: java.lang.NullPointerException
10-27 20:28:41.202: E/AndroidRuntime(3232):     at com.bignerdranch.andriod.geoquiz.QuizActivity.onCreate(QuizActivity.java:57)
10-27 20:28:41.202: E/AndroidRuntime(3232):     at android.app.Activity.performCreate(Activity.java:5104)
10-27 20:28:41.202: E/AndroidRuntime(3232):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
10-27 20:28:41.202: E/AndroidRuntime(3232):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
10-27 20:28:41.202: E/AndroidRuntime(3232):     ... 11 more


我不能点击任何地方。

4

1 回答 1

4

您只能双击 logcat 中提到您的包名称的行。您不能双击 LogCat 中的所有行

例如,对于这个 LogCat

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.exampl.sample5/com.exampl.sample5.MainActivity}: java.lang.NullPointerException
10-27 23:06:22.269: E/AndroidRuntime(348):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
10-27 23:06:22.269: E/AndroidRuntime(348):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
10-27 23:06:22.269: E/AndroidRuntime(348):  at android.app.ActivityThread.access$1500(ActivityThread.java:117)
10-27 23:06:22.269: E/AndroidRuntime(348):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
10-27 23:06:22.269: E/AndroidRuntime(348):  at android.os.Handler.dispatchMessage(Handler.java:99)
10-27 23:06:22.269: E/AndroidRuntime(348):  at android.os.Looper.loop(Looper.java:123)
10-27 23:06:22.269: E/AndroidRuntime(348):  at android.app.ActivityThread.main(ActivityThread.java:3683)
10-27 23:06:22.269: E/AndroidRuntime(348):  at java.lang.reflect.Method.invokeNative(Native Method)
10-27 23:06:22.269: E/AndroidRuntime(348):  at java.lang.reflect.Method.invoke(Method.java:507)
10-27 23:06:22.269: E/AndroidRuntime(348):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
10-27 23:06:22.269: E/AndroidRuntime(348):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
10-27 23:06:22.269: E/AndroidRuntime(348):  at dalvik.system.NativeStart.main(Native Method)
10-27 23:06:22.269: E/AndroidRuntime(348): Caused by: java.lang.NullPointerException
10-27 23:06:22.269: E/AndroidRuntime(348):  at com.example.sample.MainActivity.onCreate(MainActivity.java:19)
10-27 23:06:22.269: E/AndroidRuntime(348):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
10-27 23:06:22.269: E/AndroidRuntime(348):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
10-27 23:06:22.269: E/AndroidRuntime(348):  ... 11 more

由于com.example.sample是我的包名,双击com.example.sample.MainActivity.onCreate(MainActivity.java:19)该行将在代码中显示该行。

于 2013-10-27T17:30:57.873 回答