2

我正在开发一个使用 google apis 服务的 android 应用程序。

当我在家中使用 wifi 发出请求时,一切正常,但是当我在企业网络中时,请求失败。

logcat 提取

03-12 09:51:36.279: W/System.err(1213): java.net.SocketTimeoutException: failed          
to connect to maps.googleapis.com/74.125.132.95 (port 443) after 20000ms 03-12                           
09:51:36.299: W/System.err(1213): at libcore.io.IoBridge.connectErrno(IoBridge.java:159)
03-12 09:51:36.379: W/System.err(1213): at libcore.io.IoBridge.connect(IoBridge.java:112)
03-12 09:51:36.389: W/System.err(1213): at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:192)
03-12 09:51:36.389: W/System.err(1213): at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:459)
03-12 09:51:36.399: W/System.err(1213): at java.net.Socket.connect(Socket.java:842)
03-12 09:51:36.410: W/System.err(1213): at libcore.net.http.HttpConnection.<init>(HttpConnection.java:76)
03-12 09:51:36.410: W/System.err(1213): at libcore.net.http.HttpConnection.<init>(HttpConnection.java:50)
03-12 09:51:36.410: W/System.err(1213): at libcore.net.http.HttpConnection$Address.connect(HttpConnection.java:340)
03-12 09:51:36.419: W/System.err(1213): at libcore.net.http.HttpConnectionPool.get(HttpConnectionPool.java:87)
03-12 09:51:36.419: W/System.err(1213): at libcore.net.http.HttpConnection.connect(HttpConnection.java:128)
03-12 09:51:36.430: W/System.err(1213): at libcore.net.http.HttpEngine.openSocketConnection(HttpEngine.java:316)
03-12 09:51:36.430: W/System.err(1213): at libcore.net.http.HttpsURLConnectionImpl$HttpsEngine.makeSslConnection(HttpsURLConnectionImpl.java:461)
03-12 09:51:36.479: W/System.err(1213): at libcore.net.http.HttpsURLConnectionImpl$HttpsEngine.connect(HttpsURLConnectionImpl.java:442 )
03-12 09:51:36.489: W/System.err(1213): at libcore.net.http.HttpEngine.sendSocketRequest(HttpEngine.java:290)
03-12 09:51:36.489: W/System.err(1213): at libcore.net.http.HttpEngine.sendRequest(HttpEngine.java:240)
03-12 09:51:36.489: W/System.err(1213): at libcore.net.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:81)
03-12 09:51:36.509: W/System.err(1213): at libcore.net.http.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java:165)
03-12 09:51:36.509: W/System.err(1213): at com.google.api.client.http.javanet.NetHttpRequest.execute(NetHttpRequest.java:90)
03-12 09:51:36.520: W/System.err(1213): at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:895)
03-12 09:51:36.530: W/System.err(1213): at com.androidhive.googleplacesandmaps.GooglePlaces.search(GooglePlaces.java:63)
03-12 09:51:36.530: W/System.err(1213): at com.androidhive.googleplacesandmaps.MainActivity$LoadPlaces.doInBackground(MainActivity.java:183)
03-12 09:51:36.530: W/System.err(1213): at com.androidhive.googleplacesandmaps.MainActivity$LoadPlaces.doInBackground(MainActivity.java:1)
03-12 09:51:36.582: W/System.err(1213): at android.os.AsyncTask$2.call(AsyncTask.java:287)
03-12 09:51:36.589: W/System.err(1213): at java.util.concurrent.FutureTask.run(FutureTask.java:234)
03-12 09:51:36.589: W/System.err(1213): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
03-12 09:51:36.599: W/System.err(1213): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
03-12 09:51:36.609: W/System.err(1213): at java.lang.Thread.run(Thread.java:856)
03-12 09:51:36.620: D/AndroidRuntime(1213): Shutting down VM
03-12 09:51:36.620: W/dalvikvm(1213): threadid=1: thread exiting with uncaught exception (group=0x40a71930)
03-12 09:51:36.649: E/AndroidRuntime(1213): FATAL EXCEPTION: main
03-12 09:51:36.649: E/AndroidRuntime(1213): java.lang.NullPointerException
03-12 09:51:36.649: E/AndroidRuntime(1213): at com.androidhive.googleplacesandmaps.MainActivity$LoadPlaces$1.run(MainActivity.java:209)
03-12 09:51:36.649: E/AndroidRuntime(1213): at android.app.Activity.runOnUiThread(Activity.java:4644)
03-12 09:51:36.649: E/AndroidRuntime(1213): at com.androidhive.googleplacesandmaps.MainActivity$LoadPlaces.onPostExecute(MainActivity.java:203)
03-12 09:51:36.649: E/AndroidRuntime(1213): at com.androidhive.googleplacesandmaps.MainActivity$LoadPlaces.onPostExecute(MainActivity.java:1)
03-12 09:51:36.649: E/AndroidRuntime(1213): at android.os.AsyncTask.finish(AsyncTask.java:631)
03-12 09:51:36.649: E/AndroidRuntime(1213): at android.os.AsyncTask.access$600(AsyncTask.java:177)
03-12 09:51:36.649: E/AndroidRuntime(1213): at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:644)
03-12 09:51:36.649: E/AndroidRuntime(1213): at android.os.Handler.dispatchMessage(Handler.java:99)
03-12 09:51:36.649: E/AndroidRuntime(1213): at android.os.Looper.loop(Looper.java:137)
03-12 09:51:36.649: E/AndroidRuntime(1213): at android.app.ActivityThread.main(ActivityThread.java:5041)
03-12 09:51:36.649: E/AndroidRuntime(1213): at java.lang.reflect.Method.invokeNative(Native Method)
03-12 09:51:36.649: E/AndroidRuntime(1213): at java.lang.reflect.Method.invoke(Method.java:511)
03-12 09:51:36.649: E/AndroidRuntime(1213): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
03-12 09:51:36.649: E/AndroidRuntime(1213): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
03-12 09:51:36.649: E/AndroidRuntime(1213): at dalvik.system.NativeStart.main(Native Method)
03-12 09:56:36.880: I/Process(1213): Sending signal. PID: 1213 SIG: 9

我已经用谷歌搜索了,但我没有任何有用的解决方案。我尝试增加连接超时但没有运气。

真的不知道是什么导致了问题,因为企业的 wifi 工作正常,但对于这个网站:maps.googleapis.com

4

1 回答 1

2

因为我在代理后面工作,所以我已经完成了这些步骤,之后我没有收到这个错误:

  1. 要知道我支持的代理,我使用了这篇文章https://superuser.com/questions/346372/how-do-i-know-what-proxy-server-im-using

  2. 在模拟器中,我转到“无线和网络设置”->“移动网络”->“接入点名称,并使用在 wpad.dat 文件中找到的端口设置代理名称

  3. 在运行配置 > Android 应用程序 > 应用程序 > 目标 > 附加模拟器命令行选项:-http-proxy http://:

我希望它会帮助别人!

于 2013-03-19T13:47:40.500 回答