來自Python我現在正在嘗試創建一個Android應用程序。在這種情況下,我有時會遇到錯誤,例如NullPointerException。問題是,與Python不同,Eclipse不告訴我發生錯誤的行號。這給了我這樣的事情:如何讓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),這確實是它發生的路線。
那麼,讓我們把這個問題放在這裏吧。我是否可以只顯示自己寫的代碼中的錯誤,而不顯示所有其他的巨型代碼中的錯誤?
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
調試行由行? –
請張貼你如何登錄例外。而且,這是整個堆棧跟蹤? – ppeterka
您可能正在捕捉異常並且不打印堆棧跟蹤。 – njzk2