0
我正在android上創建一個列表來添加任務,當我運行它並且模擬器啓動時有很多錯誤。我努力解決這些問題,但我做不到,我認爲這是主要的它應該顯示所有任務已經停止,窗口泄漏,zygoteInit
在這裏一類問題是日誌貓
04-08 08:53:43.334: E/Trace(637): error opening trace file: No such file or directory (2)
04-08 08:53:45.043: I/Choreographer(637): Skipped 54 frames! The application may be doing too much work on its main thread.
04-08 08:53:45.144: D/gralloc_goldfish(637): Emulator without GPU emulation detected.
04-08 08:53:45.479: I/Choreographer(637): Skipped 35 frames! The application may be doing too much work on its main thread.
04-08 08:53:46.067: I/Choreographer(637): Skipped 56 frames! The application may be doing too much work on its main thread.
04-08 08:53:46.713: D/dalvikvm(637): GC_CONCURRENT freed 132K, 2% free 9089K/9268K, paused 9ms+3ms, total 102ms
04-08 08:53:46.803: E/JSON Parser(637): Error parsing data org.json.JSONException: Value <br of type java.lang.String cannot be converted to JSONObject
04-08 08:53:46.843: W/dalvikvm(637): threadid=11: thread exiting with uncaught exception (group=0x2bd39930)
04-08 08:53:46.903: E/AndroidRuntime(637): FATAL EXCEPTION: AsyncTask #1
04-08 08:53:46.903: E/AndroidRuntime(637): java.lang.RuntimeException: An error occured while executing doInBackground()
04-08 08:53:46.903: E/AndroidRuntime(637): at android.os.AsyncTask$3.done(AsyncTask.java:299)
04-08 08:53:46.903: E/AndroidRuntime(637): at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:352)
04-08 08:53:46.903: E/AndroidRuntime(637): at java.util.concurrent.FutureTask.setException(FutureTask.java:219)
04-08 08:53:46.903: E/AndroidRuntime(637): at java.util.concurrent.FutureTask.run(FutureTask.java:239)
04-08 08:53:46.903: E/AndroidRuntime(637): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
04-08 08:53:46.903: E/AndroidRuntime(637): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
04-08 08:53:46.903: E/AndroidRuntime(637): at java.lang.Thread.run(Thread.java:856)
04-08 08:53:46.903: E/AndroidRuntime(637): Caused by: java.lang.NullPointerException
04-08 08:53:46.903: E/AndroidRuntime(637): at com.example.checklist.MainTask$LoadAllTasks.doInBackground(MainTask.java:172)
04-08 08:53:46.903: E/AndroidRuntime(637): at com.example.checklist.MainTask$LoadAllTasks.doInBackground(MainTask.java:1)
04-08 08:53:46.903: E/AndroidRuntime(637): at android.os.AsyncTask$2.call(AsyncTask.java:287)
04-08 08:53:46.903: E/AndroidRuntime(637): at java.util.concurrent.FutureTask.run(FutureTask.java:234)
04-08 08:53:46.903: E/AndroidRuntime(637): ... 3 more
04-08 08:53:51.744: E/WindowManager(637): Activity com.example.checklist.MainTask has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView{2c607c90 V.E..... R.....ID 0,0-684,192} that was originally added here
04-08 08:53:51.744: E/WindowManager(637): android.view.WindowLeaked: Activity com.example.checklist.MainTask has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView{2c607c90 V.E..... R.....ID 0,0-684,192} that was originally added here
04-08 08:53:51.744: E/WindowManager(637): at android.view.ViewRootImpl.<init>(ViewRootImpl.java:354)
04-08 08:53:51.744: E/WindowManager(637): at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:216)
04-08 08:53:51.744: E/WindowManager(637): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:69)
04-08 08:53:51.744: E/WindowManager(637): at android.app.Dialog.show(Dialog.java:281)
04-08 08:53:51.744: E/WindowManager(637): at com.example.checklist.MainTask$LoadAllTasks.onPreExecute(MainTask.java:155)
04-08 08:53:51.744: E/WindowManager(637): at android.os.AsyncTask.executeOnExecutor(AsyncTask.java:586)
04-08 08:53:51.744: E/WindowManager(637): at android.os.AsyncTask.execute(AsyncTask.java:534)
04-08 08:53:51.744: E/WindowManager(637): at com.example.checklist.MainTask.onCreate(MainTask.java:79)
04-08 08:53:51.744: E/WindowManager(637): at android.app.Activity.performCreate(Activity.java:5104)
04-08 08:53:51.744: E/WindowManager(637): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
04-08 08:53:51.744: E/WindowManager(637): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
04-08 08:53:51.744: E/WindowManager(637): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
04-08 08:53:51.744: E/WindowManager(637): at android.app.ActivityThread.access$600(ActivityThread.java:141)
04-08 08:53:51.744: E/WindowManager(637): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
04-08 08:53:51.744: E/WindowManager(637): at android.os.Handler.dispatchMessage(Handler.java:99)
04-08 08:53:51.744: E/WindowManager(637): at android.os.Looper.loop(Looper.java:137)
04-08 08:53:51.744: E/WindowManager(637): at android.app.ActivityThread.main(ActivityThread.java:5039)
04-08 08:53:51.744: E/WindowManager(637): at java.lang.reflect.Method.invokeNative(Native Method)
04-08 08:53:51.744: E/WindowManager(637): at java.lang.reflect.Method.invoke(Method.java:511)
04-08 08:53:51.744: E/WindowManager(637): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
04-08 08:53:51.744: E/WindowManager(637): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
04-08 08:53:51.744: E/WindowManager(637): at dalvik.system.NativeStart.main(Native Method)
04-08 08:53:51.744: I/Choreographer(637): Skipped 49 frames! The application may be doing too much work on its main thread.
04-08 08:53:57.493: I/Process(637): Sending signal. PID: 637 SIG: 9
這裏的代碼非常類似於http://stackoverflow.com/questions/13295875/start-activity-in-doinbackground-method考慮添加一條註釋到 – 2013-04-08 09:11:47
引起:java.lang.NullPointerException在行號172.這條線是什麼? – Kanth 2013-04-08 09:14:34
避免NullPointer異常的好方法是檢查該對象是否爲空。然後做getter或setter操作。有些像這樣if(object!= null){//用這個對象做某事}。這樣您可以避免由於空指針異常而導致崩潰。 – RockandRoll 2013-04-08 09:26:37