来自 Python,我现在正在尝试创建一个 Android 应用程序。在这种情况下,我有时会遇到错误,例如 NullPointerException。问题在于,与 Python 不同,Eclipse 不会告诉我发生错误的行号。它只是给了我这样的东西:
10-09 10:03:59.379: E/AndroidRuntime(3289): java.lang.RuntimeException: Unable to resume activity {com.example.android/com.example.android.ui.MyActivity}: java.lang.NullPointerException
有没有办法让 Eclipse 告诉我发生 NullPointerException 的行?
=== 编辑=== 啊,我现在查看完整错误的详细信息(如下),在那里我看到这一行:om.example.android.ui.MyActivity.onResume(MyActivity.java:208),即确实是它发生的那条线。
所以让我们这样提出我的问题。我可以只显示我自己编写的代码中的错误,而不是所有其他的 mumbo-jumbo 吗?
10-09 10:08:49.759: E/AndroidRuntime(3502): java.lang.RuntimeException: Unable to resume activity {com.example.android/com.example.android.ui.MyActivity}: java.lang.NullPointerException
10-09 10:08:49.759: E/AndroidRuntime(3502): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2790)
10-09 10:08:49.759: E/AndroidRuntime(3502): at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2819)
10-09 10:08:49.759: E/AndroidRuntime(3502): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2266)
10-09 10:08:49.759: E/AndroidRuntime(3502): at android.app.ActivityThread.access$600(ActivityThread.java:141)
10-09 10:08:49.759: E/AndroidRuntime(3502): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
10-09 10:08:49.759: E/AndroidRuntime(3502): at android.os.Handler.dispatchMessage(Handler.java:99)
10-09 10:08:49.759: E/AndroidRuntime(3502): at android.os.Looper.loop(Looper.java:137)
10-09 10:08:49.759: E/AndroidRuntime(3502): at android.app.ActivityThread.main(ActivityThread.java:5103)
10-09 10:08:49.759: E/AndroidRuntime(3502): at java.lang.reflect.Method.invokeNative(Native Method)
10-09 10:08:49.759: E/AndroidRuntime(3502): at java.lang.reflect.Method.invoke(Method.java:525)
10-09 10:08:49.759: E/AndroidRuntime(3502): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
10-09 10:08:49.759: E/AndroidRuntime(3502): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
10-09 10:08:49.759: E/AndroidRuntime(3502): at dalvik.system.NativeStart.main(Native Method)
10-09 10:08:49.759: E/AndroidRuntime(3502): Caused by: java.lang.NullPointerException
10-09 10:08:49.759: E/AndroidRuntime(3502): at com.example.android.ui.widget.AmountFragment.setAmount(AmountFragment.java:79)
10-09 10:08:49.759: E/AndroidRuntime(3502): at com.example.android.ui.MyActivity.onResume(MyActivity.java:208)
10-09 10:08:49.759: E/AndroidRuntime(3502): at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1192)
10-09 10:08:49.759: E/AndroidRuntime(3502): at android.app.Activity.performResume(Activity.java:5211)
10-09 10:08:49.759: E/AndroidRuntime(3502): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2780)
10-09 10:08:49.759: E/AndroidRuntime(3502): ... 12 more