无法从Android设备访问计算机上运行的GAE服务器
我正在尝试我的第一个GAE服务器和Android连接。我在我的电脑(192.168.1.24)上通过Android ADT运行GAE服务器。我的Android设备通过USB以开发者模式连接。我正在尝试从设备发出HTTP请求并存储响应。但是我得到了下面的错误无法从Android设备访问计算机上运行的GAE服务器,android,eclipse,google-app-engine,adt,Android,Eclipse,Google App Engine,Adt,我正在尝试我的第一个GAE服务器和Android连接。我在我的电脑(192.168.1.24)上通过Android ADT运行GAE服务器。我的Android设备通过USB以开发者模式连接。我正在尝试从设备发出HTTP请求并存储响应。但是我得到了下面的错误 02-23 03:10:22.915: E/AndroidRuntime(18076): FATAL EXCEPTION: main 02-23 03:10:22.915: E/AndroidRuntime(18076): java.lang
02-23 03:10:22.915: E/AndroidRuntime(18076): FATAL EXCEPTION: main
02-23 03:10:22.915: E/AndroidRuntime(18076): java.lang.IllegalStateException: Could not execute method of the activity
02-23 03:10:22.915: E/AndroidRuntime(18076): at android.view.View$1.onClick(View.java:3838)
02-23 03:10:22.915: E/AndroidRuntime(18076): at android.view.View.performClick(View.java:4475)
02-23 03:10:22.915: E/AndroidRuntime(18076): at android.view.View$PerformClick.run(View.java:18796)
02-23 03:10:22.915: E/AndroidRuntime(18076): at android.os.Handler.handleCallback(Handler.java:730)
02-23 03:10:22.915: E/AndroidRuntime(18076): at android.os.Handler.dispatchMessage(Handler.java:92)
02-23 03:10:22.915: E/AndroidRuntime(18076): at android.os.Looper.loop(Looper.java:137)
02-23 03:10:22.915: E/AndroidRuntime(18076): at android.app.ActivityThread.main(ActivityThread.java:5455)
02-23 03:10:22.915: E/AndroidRuntime(18076): at java.lang.reflect.Method.invokeNative(Native Method)
02-23 03:10:22.915: E/AndroidRuntime(18076): at java.lang.reflect.Method.invoke(Method.java:525)
02-23 03:10:22.915: E/AndroidRuntime(18076): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1187)
02-23 03:10:22.915: E/AndroidRuntime(18076): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
02-23 03:10:22.915: E/AndroidRuntime(18076): at dalvik.system.NativeStart.main(Native Method)
02-23 03:10:22.915: E/AndroidRuntime(18076): Caused by: java.lang.reflect.InvocationTargetException
02-23 03:10:22.915: E/AndroidRuntime(18076): at java.lang.reflect.Method.invokeNative(Native Method)
02-23 03:10:22.915: E/AndroidRuntime(18076): at java.lang.reflect.Method.invoke(Method.java:525)
02-23 03:10:22.915: E/AndroidRuntime(18076): at android.view.View$1.onClick(View.java:3833)
02-23 03:10:22.915: E/AndroidRuntime(18076): ... 11 more
02-23 03:10:22.915: E/AndroidRuntime(18076): Caused by: java.lang.IllegalArgumentException: Illegal character in scheme at index 0: 192.168.1.24:8889/myserver?username=qwerty&password=qwerty
02-23 03:10:22.915: E/AndroidRuntime(18076): at java.net.URI.create(URI.java:727)
02-23 03:10:22.915: E/AndroidRuntime(18076): at org.apache.http.client.methods.HttpGet.<init>(HttpGet.java:75)
02-23 03:10:22.915: E/AndroidRuntime(18076): at httprequest.GetMethods.doGetWithResponse(GetMethods.java:28)
02-23 03:10:22.915: E/AndroidRuntime(18076): at com.example.tandemstory.UserAuth.doAuth(UserAuth.java:24)
02-23 03:10:22.915: E/AndroidRuntime(18076): at com.example.tandemstory.SignIn.onSignin(SignIn.java:74)
02-23 03:10:22.915: E/AndroidRuntime(18076): ... 14 more
UserAuth.doAuth()如下所示
public static String doAuth(String username,String password) {
// CONSTRUCT GET REQUEST URL
String url = "192.168.1.24/myserver?username=qwerty&password=qwerty"
// XML RESPONSE AS A STRING GETS RETURNED
String response = GetMethods.doGetWithResponse(URL_BASE, httpClient);
return response;
}
public static String doGetWithResponse(String mUrl,DefaultHttpClient httpClient){
String ret=null;
HttpResponse response=null;
//initiate get method with username and password
HttpGet getMethod=new HttpGet(mUrl);
try{
//use http client to execute method
response=httpClient.execute(getMethod);
if(response!=null){
//convert http response to string
ret=getResponseBody(response);
}
}catch(Exception e){
e.printStackTrace();
}
return ret;
}
GetMethods.doGetWithResponse()如下所示
public static String doAuth(String username,String password) {
// CONSTRUCT GET REQUEST URL
String url = "192.168.1.24/myserver?username=qwerty&password=qwerty"
// XML RESPONSE AS A STRING GETS RETURNED
String response = GetMethods.doGetWithResponse(URL_BASE, httpClient);
return response;
}
public static String doGetWithResponse(String mUrl,DefaultHttpClient httpClient){
String ret=null;
HttpResponse response=null;
//initiate get method with username and password
HttpGet getMethod=new HttpGet(mUrl);
try{
//use http client to execute method
response=httpClient.execute(getMethod);
if(response!=null){
//convert http response to string
ret=getResponseBody(response);
}
}catch(Exception e){
e.printStackTrace();
}
return ret;
}
请给出解决方案的任何指针。异常
java.lang.IllegalArgumentException:索引0:192.168.1.24:8889/myserver?username=qwerty&password=qwerty
似乎表明可以通过尝试以下操作解决问题:
- 在URL字符串前面加上
,看看是否有效http://
- 在URL字符串前面加上
,并正确编码URL李>http://