已停止,窗户泄露,zygoteInit

时间:2013-04-08 08:59:57

标签: java android listview android-asynctask oncreate

我正在使用android创建一个列表来添加任务,当我运行它并且模拟器启动时会出现很多错误。我努力解决它们,但我不能,我认为一个类中的问题是它应该显示所有任务的主要问题

这是log cat

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

1 个答案:

答案 0 :(得分:0)

考虑到您的日志显示json解析错误后跟NPE,我的猜测是问题发生在这里:

// getting JSON string from URL 
JSONObject json = jParser.makeHttpRequest(url_all_tasks, "GET", params); 

// Check your log cat for JSON reponse 
Log.d("All Tasks: ", json.toString());

看起来解析器失败,只返回null的{​​{1}},然后调用json失败并显示NPE。

此外,您应该更改您的json.toString()代码以了解Sunil Havnur提供的评论。