Android JSON解析和异步任务错误

Android JSON解析和异步任务错误,android,json,android-asynctask,Android,Json,Android Asynctask,我正在尝试执行注册和登录功能,但JSON和AsyncTask存在问题。这是logcat错误 02-06 04:18:08.857: E/JSON(1160): <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">n<HTML><HEAD><TITLE>Not Found</TITLE>n<META HTTP

我正在尝试执行注册和登录功能,但JSON和AsyncTask存在问题。这是logcat错误

02-06 04:18:08.857: E/JSON(1160): <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">n<HTML><HEAD><TITLE>Not Found</TITLE>n<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>n<BODY><h2>Not Found</h2>n<hr><p>HTTP Error 404. The requested resource is not found.</p>n</BODY></HTML>n
02-06 04:18:08.857: E/JSON Parser(1160): Error parsing data org.json.JSONException: Value <!DOCTYPE of type java.lang.String cannot be converted to JSONObject
02-06 04:18:08.887: W/dalvikvm(1160): threadid=11: thread exiting with uncaught exception (group=0x41465700)
02-06 04:18:08.937: E/AndroidRuntime(1160): FATAL EXCEPTION: AsyncTask #1
02-06 04:18:08.937: E/AndroidRuntime(1160): java.lang.RuntimeException: An error occured  while executing doInBackground()
02-06 04:18:08.937: E/AndroidRuntime(1160):     at android.os.AsyncTask$3.done(AsyncTask.java:299)
02-06 04:18:08.937: E/AndroidRuntime(1160):     at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:352)
02-06 04:18:08.937: E/AndroidRuntime(1160):     at java.util.concurrent.FutureTask.setException(FutureTask.java:219)
02-06 04:18:08.937: E/AndroidRuntime(1160):     at java.util.concurrent.FutureTask.run(FutureTask.java:239)
02-06 04:18:08.937: E/AndroidRuntime(1160):     at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
02-06 04:18:08.937: E/AndroidRuntime(1160):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
02-06 04:18:08.937: E/AndroidRuntime(1160):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
02-06 04:18:08.937: E/AndroidRuntime(1160):     at java.lang.Thread.run(Thread.java:841)
02-06 04:18:08.937: E/AndroidRuntime(1160): Caused by: java.lang.NullPointerException
02-06 04:18:08.937: E/AndroidRuntime(1160):     at my.fyp.inticlassifieds.RegisterTask.doInBackground(RegisterTask.java:76)
02-06 04:18:08.937: E/AndroidRuntime(1160):     at my.fyp.inticlassifieds.RegisterTask.doInBackground(RegisterTask.java:1)
02-06 04:18:08.937: E/AndroidRuntime(1160):     at android.os.AsyncTask$2.call(AsyncTask.java:287)
02-06 04:18:08.937: E/AndroidRuntime(1160):     at java.util.concurrent.FutureTask.run(FutureTask.java:234)
02-06 04:18:08.937: E/AndroidRuntime(1160):     ... 4 more
02-06 04:18:08.857:E/JSON(1160):找不到找不到HTTP错误404。找不到请求的资源。

nn 02-06 04:18:08.857:E/JSON解析器(1160):解析数据org.JSON.JSONException:Value时出错
更改链接,现在我有这个错误

02-06 09:45:18.168: E/JSON(1697): <br />n<font size='1'><table class='xdebug-error' dir='ltr' border='1' cellspacing='0' cellpadding='1'>n<tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> Warning: require_once(include/DB_Functions.php) [<a href='function.require-once'>function.require-once</a>]: failed to open stream: No such file or directory in D:\Softwares\wamp\www\project\index.php on line <i>17</i></th></tr>n<tr><th align='left' bgcolor='#e9b96e' colspan='5'>Call Stack</th></tr>n<tr><th align='center' bgcolor='#eeeeec'>#</th><th align='left' bgcolor='#eeeeec'>Time</th><th align='left' bgcolor='#eeeeec'>Memory</th><th align='left' bgcolor='#eeeeec'>Function</th><th align='left' bgcolor='#eeeeec'>Location</th></tr>n<tr><td bgcolor='#eeeeec' align='center'>1</td><td bgcolor='#eeeeec' align='center'>0.0009</td><td bgcolor='#eeeeec' align='right'>692600</td><td bgcolor='#eeeeec'>{main}(  )</td><td title='D:\Softwares\wamp\www\project\index.php' bgcolor='#eeeeec'>..\index.php<b>:</b>0</td></tr>n</table></font>n<br />n<font size='1'><table class='xdebug-error' dir='ltr' border='1' cellspacing='0' cellpadding='1'>n<tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> Fatal error: require_once() [<a href='function.require'>function.require</a>]: Failed opening required 'include/DB_Functions.php' (include_path='.;C:\php\pear') in D:\Softwares\wamp\www\project\index.php on line <i>17</i></th></tr>n<tr><th align='left' bgcolor='#e9b96e' colspan='5'>Call Stack</th></tr>n<tr><th align='center' bgcolor='#eeeeec'>#</th><th align='left' bgcolor='#eeeeec'>Time</th><th align='left' bgcolor='#eeeeec'>Memory</th><th align='left' bgcolor='#eeeeec'>Function</th><th align='left' bgcolor='#eeeeec'>Location</th></tr>n<tr><td bgcolor='#eeeeec' align='center'>1</td><td bgcolor='#eeeeec' align='center'>0.0009</td><td bgcolor='#eeeeec' align='right'>692600</td><td bgcolor='#eeeeec'>{main}(  )</td><td title='D:\Softwares\wamp\www\project\index.php' bgcolor='#eeeeec'>..\index.php<b>:</b>0</td></tr>n</table></font>n
02-06 09:45:18.168:E/JSON(1697):
nn(!)警告:require_once(include/DB_Functions.php)[]:无法打开流:在17nCall Stackn#TimeMemoryFunctionLocationn10.0009692600{main}()..\index.php:0nn
nn(!)行上的D:\Softwares\wamp\www\project\index.php中没有这样的文件或目录致命错误:require u once()]:在17nCall Stackn#TimeMemoryFunctionLocationn10.0009692600{main}()..\index.php行的D:\Softwares\wamp\www\project\index.php中打开所需的“include/DB\u Functions.php”(include\php路径=”;C:\php\pear')失败
您指向错误的url:404-未找到

这就是您试图解析的内容:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">n<HTML><HEAD><TITLE>Not Found</TITLE>n<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>n<BODY><h2>Not Found</h2>n<hr><p>HTTP Error 404. The requested resource is not found.</p>n</BODY></HTML>
HTTP错误404。找不到请求的资源。

n
正如您所看到的,这不是一个JSON,而是一个HTML页面。测试直接从浏览器指向它的url。您应该会看到一个JSON格式的字符串。

使用了错误的url。您将得到404错误页面作为响应,并尝试将html解析为JSON。

值!DOCTYPE“查看你的url,servlet或firewall cfg

你在RegisterTask.java:76.中有NPE。那是哪一行?@M.Sameer如果(json.getString(KEY_SUCCESS)!=null)我应该放什么url?@firaga我猜你的php页面的url。
02-06 09:45:18.168: E/JSON(1697): <br />n<font size='1'><table class='xdebug-error' dir='ltr' border='1' cellspacing='0' cellpadding='1'>n<tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> Warning: require_once(include/DB_Functions.php) [<a href='function.require-once'>function.require-once</a>]: failed to open stream: No such file or directory in D:\Softwares\wamp\www\project\index.php on line <i>17</i></th></tr>n<tr><th align='left' bgcolor='#e9b96e' colspan='5'>Call Stack</th></tr>n<tr><th align='center' bgcolor='#eeeeec'>#</th><th align='left' bgcolor='#eeeeec'>Time</th><th align='left' bgcolor='#eeeeec'>Memory</th><th align='left' bgcolor='#eeeeec'>Function</th><th align='left' bgcolor='#eeeeec'>Location</th></tr>n<tr><td bgcolor='#eeeeec' align='center'>1</td><td bgcolor='#eeeeec' align='center'>0.0009</td><td bgcolor='#eeeeec' align='right'>692600</td><td bgcolor='#eeeeec'>{main}(  )</td><td title='D:\Softwares\wamp\www\project\index.php' bgcolor='#eeeeec'>..\index.php<b>:</b>0</td></tr>n</table></font>n<br />n<font size='1'><table class='xdebug-error' dir='ltr' border='1' cellspacing='0' cellpadding='1'>n<tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> Fatal error: require_once() [<a href='function.require'>function.require</a>]: Failed opening required 'include/DB_Functions.php' (include_path='.;C:\php\pear') in D:\Softwares\wamp\www\project\index.php on line <i>17</i></th></tr>n<tr><th align='left' bgcolor='#e9b96e' colspan='5'>Call Stack</th></tr>n<tr><th align='center' bgcolor='#eeeeec'>#</th><th align='left' bgcolor='#eeeeec'>Time</th><th align='left' bgcolor='#eeeeec'>Memory</th><th align='left' bgcolor='#eeeeec'>Function</th><th align='left' bgcolor='#eeeeec'>Location</th></tr>n<tr><td bgcolor='#eeeeec' align='center'>1</td><td bgcolor='#eeeeec' align='center'>0.0009</td><td bgcolor='#eeeeec' align='right'>692600</td><td bgcolor='#eeeeec'>{main}(  )</td><td title='D:\Softwares\wamp\www\project\index.php' bgcolor='#eeeeec'>..\index.php<b>:</b>0</td></tr>n</table></font>n
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">n<HTML><HEAD><TITLE>Not Found</TITLE>n<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>n<BODY><h2>Not Found</h2>n<hr><p>HTTP Error 404. The requested resource is not found.</p>n</BODY></HTML>