-1

我正在制作这个应用程序,它有一个允许用户登录的活动,程序检查数据库中的信息,然后将用户发送到仪表板屏幕。它一直运行良好,但现在我遇到了一些奇怪的错误,我无法弄清楚它们来自哪里。

这是日志猫:

01-18 14:54:22.160: E/AndroidRuntime(2621): FATAL EXCEPTION: AsyncTask #5
01-18 14:54:22.160: E/AndroidRuntime(2621): java.lang.RuntimeException: An error occured while executing doInBackground()
01-18 14:54:22.160: E/AndroidRuntime(2621):     at android.os.AsyncTask$3.done(AsyncTask.java:299)
01-18 14:54:22.160: E/AndroidRuntime(2621):     at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:352)
01-18 14:54:22.160: E/AndroidRuntime(2621):     at java.util.concurrent.FutureTask.setException(FutureTask.java:219)
01-18 14:54:22.160: E/AndroidRuntime(2621):     at java.util.concurrent.FutureTask.run(FutureTask.java:239)
01-18 14:54:22.160: E/AndroidRuntime(2621):     at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
01-18 14:54:22.160: E/AndroidRuntime(2621):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
01-18 14:54:22.160: E/AndroidRuntime(2621):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
01-18 14:54:22.160: E/AndroidRuntime(2621):     at java.lang.Thread.run(Thread.java:856)
01-18 14:54:22.160: E/AndroidRuntime(2621): Caused by: java.lang.IllegalStateException: Target host must not be null, or set in parameters. scheme=null, host=null, path=192.168.0.2/android_login/
01-18 14:54:22.160: E/AndroidRuntime(2621):     at org.apache.http.impl.client.DefaultRequestDirector.determineRoute(DefaultRequestDirector.java:591)
01-18 14:54:22.160: E/AndroidRuntime(2621):     at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:293)
01-18 14:54:22.160: E/AndroidRuntime(2621):     at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
01-18 14:54:22.160: E/AndroidRuntime(2621):     at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
01-18 14:54:22.160: E/AndroidRuntime(2621):     at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
01-18 14:54:22.160: E/AndroidRuntime(2621):     at com.example.androidbasic12.library.JSONParser.getJSONFromUrl(JSONParser.java:42)
01-18 14:54:22.160: E/AndroidRuntime(2621):     at com.example.androidbasic12.library.UserFunctions.loginUser(UserFunctions.java:40)
01-18 14:54:22.160: E/AndroidRuntime(2621):     at com.example.androidbasic12.MainActivity$LoginTask.doInBackground(MainActivity.java:78)
01-18 14:54:22.160: E/AndroidRuntime(2621):     at com.example.androidbasic12.MainActivity$LoginTask.doInBackground(MainActivity.java:1)
01-18 14:54:22.160: E/AndroidRuntime(2621):     at android.os.AsyncTask$2.call(AsyncTask.java:287)
01-18 14:54:22.160: E/AndroidRuntime(2621):     at java.util.concurrent.FutureTask.run(FutureTask.java:234)
01-18 14:54:22.160: E/AndroidRuntime(2621):     ... 4 more

任何人都可以看到这里的问题是什么?

4

2 回答 2

0

我认为您不能拥有带下划线的 URL,请尝试将其删除。请参阅此帖子的已接受答案:目标主机不得为空,或在参数中设置

于 2013-01-18T15:03:44.930 回答
0

如日志:

IllegalStateException:目标主机不能为空,或在参数中设置

表示您尚未在 URL 中添加协议(http 或 https)。尝试将 URL 更改为:

String yoururl="http://xxx.xxx.x.x";
于 2013-01-18T15:08:05.617 回答