2012-08-03 178 views
0

我工作的一個機器人項目,當我試圖使用PHP文件登錄應用和的EasyPHP/MySQL的,它沒有失敗,這裏的logcat的錯誤:連接到數據庫的MySQL在Android

08-03 04:53:20.203: W/System.err(244): org.apache.http.NoHttpResponseException: The  target server failed to respond 
    08-03 04:53:20.237: W/System.err(244): at org.apache.http.impl.conn.DefaultResponseParser.parseHead(DefaultResponseParser.java:85) 
    08-03 04:53:20.247: W/System.err(244): at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:174) 
    08-03 04:53:20.247: W/System.err(244): at org.apache.http.impl.AbstractHttpClientConnection.receiveResponseHeader(AbstractHttpClientConnection.java:179) 
    08-03 04:53:20.247: W/System.err(244): at org.apache.http.impl.conn.DefaultClientConnection.receiveResponseHeader(DefaultClientConnection.java:235) 
    08-03 04:53:20.260: W/System.err(244): at org.apache.http.impl.conn.AbstractClientConnAdapter.receiveResponseHeader(AbstractClientConnAdapter.java:259) 
    08-03 04:53:20.260: W/System.err(244): at org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:279) 
    08-03 04:53:20.260: W/System.err(244): at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:121) 
    08-03 04:53:20.282: W/System.err(244): at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:410) 
    08-03 04:53:20.288: W/System.err(244): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555) 
    08-03 04:53:20.300: W/System.err(244): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487) 
    08-03 04:53:20.307: W/System.err(244): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465) 
    08-03 04:53:20.320: W/System.err(244): at com.stage.sondage.Login.onClick(Login.java:109) 
    08-03 04:53:20.320: W/System.err(244): at android.view.View.performClick(View.java:2364) 
    08-03 04:53:20.339: W/System.err(244): at android.view.View.onTouchEvent(View.java:4179) 
    08-03 04:53:20.358: W/System.err(244): at android.widget.TextView.onTouchEvent(TextView.java:6540) 
    08-03 04:53:20.358: W/System.err(244): at android.view.View.dispatchTouchEvent(View.java:3709) 
    08-03 04:53:20.367: W/System.err(244): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884) 
    08-03 04:53:20.379: W/System.err(244): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884) 
    08-03 04:53:20.387: W/System.err(244): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884) 
    08-03 04:53:20.401: W/System.err(244): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884) 
    08-03 04:53:20.401: W/System.err(244): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884) 
    08-03 04:53:20.401: W/System.err(244): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884) 
    08-03 04:53:20.407: W/System.err(244): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1659) 
    08-03 04:53:20.420: W/System.err(244): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1107) 
    08-03 04:53:20.420: W/System.err(244): at android.app.Activity.dispatchTouchEvent(Activity.java:2061) 
    08-03 04:53:20.420: W/System.err(244): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1643) 
    08-03 04:53:20.420: W/System.err(244): at android.view.ViewRoot.handleMessage(ViewRoot.java:1691) 
    08-03 04:53:20.427: W/System.err(244): at android.os.Handler.dispatchMessage(Handler.java:99) 
    08-03 04:53:20.438: W/System.err(244): at android.os.Looper.loop(Looper.java:123) 
    08-03 04:53:20.459: W/System.err(244): at android.app.ActivityThread.main(ActivityThread.java:4363) 
    08-03 04:53:20.459: W/System.err(244): at java.lang.reflect.Method.invokeNative(Native Method) 
    08-03 04:53:20.459: W/System.err(244): at java.lang.reflect.Method.invoke(Method.java:521) 
    08-03 04:53:20.459: W/System.err(244): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860) 
    08-03 04:53:20.467: W/System.err(244): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) 
    08-03 04:53:20.517: W/System.err(244): at dalvik.system.NativeStart.main(Native Method) 

行登錄時輸入109是response = hhtpclient.execute(httppost);

其中response是HttpResponse的一個實例;我試圖與這兩個值

httppost=new HttpPost("http://10.0.2.2/android/connection.php"); 

httppost=new HttpPost("http://127.0.1.1/android/connection.php"); 

(由什麼是兩個IP不會忽略的區別的方法是什麼?)

感謝,

回答

1

互聯網的權限在您的清單文件是必需的。

<uses-permission android:name="android.permission.INTERNET"/> 

將此粘貼到應用程序標籤後的清單文件中。

+0

我對我的清單有Internet權限,但問題仍然存在,logcat上出現相同的錯誤。順便說一下這個應用程序的登錄在我的朋友的計算機上工作,我複製相同的代碼,相同的PHP文件(相同的目錄),相同的數據庫,但在我的它不起作用。 感謝您的幫助 – 2012-08-03 18:04:37