2013-08-03 48 views
0
08-02 20:48:36.703: D/EditText(3575): nouy 
08-02 20:48:36.793: I/Choreographer(3575): Skipped 68 frames! The application may be doing too much work on its main thread. 
08-02 20:48:37.143: D/dalvikvm(3575): GC_CONCURRENT freed 1331K, 34% free 2956K/4428K, paused 4ms+59ms, total 137ms 
08-02 20:48:37.353: D/AndroidRuntime(3575): Shutting down VM 
08-02 20:48:37.394: W/dalvikvm(3575): threadid=1: thread exiting with uncaught exception (group=0x40a71930) 
08-02 20:48:37.443: E/AndroidRuntime(3575): FATAL EXCEPTION: main 
08-02 20:48:37.443: E/AndroidRuntime(3575): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.note/com.example.note.NoteEdit}: android.database.CursorIndexOutOfBoundsException: Index 0 requested, with a size of 0 
08-02 20:48:37.443: E/AndroidRuntime(3575):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180) 
08-02 20:48:37.443: E/AndroidRuntime(3575):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230) 
08-02 20:48:37.443: E/AndroidRuntime(3575):  at android.app.ActivityThread.access$600(ActivityThread.java:141) 
08-02 20:48:37.443: E/AndroidRuntime(3575):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234) 
08-02 20:48:37.443: E/AndroidRuntime(3575):  at android.os.Handler.dispatchMessage(Handler.java:99) 
08-02 20:48:37.443: E/AndroidRuntime(3575):  at android.os.Looper.loop(Looper.java:137) 
08-02 20:48:37.443: E/AndroidRuntime(3575):  at android.app.ActivityThread.main(ActivityThread.java:5041) 
08-02 20:48:37.443: E/AndroidRuntime(3575):  at java.lang.reflect.Method.invokeNative(Native Method) 
08-02 20:48:37.443: E/AndroidRuntime(3575):  at java.lang.reflect.Method.invoke(Method.java:511) 
08-02 20:48:37.443: E/AndroidRuntime(3575):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) 
08-02 20:48:37.443: E/AndroidRuntime(3575):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560) 
08-02 20:48:37.443: E/AndroidRuntime(3575):  at dalvik.system.NativeStart.main(Native Method) 
08-02 20:48:37.443: E/AndroidRuntime(3575): Caused by: android.database.CursorIndexOutOfBoundsException: Index 0 requested, with a size of 0 
08-02 20:48:37.443: E/AndroidRuntime(3575):  at android.database.AbstractCursor.checkPosition(AbstractCursor.java:424) 
08-02 20:48:37.443: E/AndroidRuntime(3575):  at android.database.AbstractWindowedCursor.checkPosition(AbstractWindowedCursor.java:136) 
08-02 20:48:37.443: E/AndroidRuntime(3575):  at android.database.AbstractWindowedCursor.getString(AbstractWindowedCursor.java:50) 
08-02 20:48:37.443: E/AndroidRuntime(3575):  at com.example.note.NoteEdit.populateFields(NoteEdit.java:231) 
08-02 20:48:37.443: E/AndroidRuntime(3575):  at com.example.note.NoteEdit.onCreate(NoteEdit.java:99) 
08-02 20:48:37.443: E/AndroidRuntime(3575):  at android.app.Activity.performCreate(Activity.java:5104) 
08-02 20:48:37.443: E/AndroidRuntime(3575):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080) 
08-02 20:48:37.443: E/AndroidRuntime(3575):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144) 
+0

請向我們展示此活動的onCreate功能。 – tier1

+0

請在代碼中將'NoteEdit.java:231'的上下文發佈。 –

+0

'引起:android.database.CursorIndexOutOfBoundsException:索引0請求,大小爲0' – Nima

回答

2

Logcat中的輸出應該從頂部讀取(在你的情況下,FATAL EXCEPTION: main起)。但是,您需要了解您的活動如何影響錯誤。在大多數情況下(並且絕對不是全部),您會發現Logcat通知您關於應用程序範圍內的一行代碼。這是個例外源自哪裏:

08-02 20:48:37.443: E/AndroidRuntime(3575): Caused by: android.database.CursorIndexOutOfBoundsException: Index 0 requested, with a size of 0 
08-02 20:48:37.443: E/AndroidRuntime(3575):  at android.database.AbstractCursor.checkPosition(AbstractCursor.java:424) 
08-02 20:48:37.443: E/AndroidRuntime(3575):  at android.database.AbstractWindowedCursor.checkPosition(AbstractWindowedCursor.java:136) 
08-02 20:48:37.443: E/AndroidRuntime(3575):  at android.database.AbstractWindowedCursor.getString(AbstractWindowedCursor.java:50) 
-------->>>>>>>>>  08-02 20:48:37.443: E/AndroidRuntime(3575):  at com.example.note.NoteEdit.populateFields(NoteEdit.java:231) 

在此之後,錯誤朝上方傳播到達前:

08-02 20:48:37.443: E/AndroidRuntime(3575): FATAL EXCEPTION: main 
08-02 20:48:37.443: E/AndroidRuntime(3575): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.note/com.example.note.NoteEdit}: android.database.CursorIndexOutOfBoundsException: Index 0 requested, with a size of 0 

另一件事要小心:異常並不總是獨立地發生。你可以堆疊一些例外。在這種情況下,找到首先拋出的異常(Logcat輸出中最低的),然後繼續工作。