I tried to integrate google play service with my unity android game. After signed in google play service, following log message appeared in DDMS and app was crashed.
02-27 13:50:00.633 13419-13419/? D/AndroidNative﹕ GameHelper: onConnected: connected! client=1
02-27 13:50:00.633 13419-13419/? D/AndroidNative﹕ GameHelper: Connected clients updated to: 1
02-27 13:50:00.633 13419-13419/? D/AndroidNative﹕ GameHelper: connectNextClient: requested clients: 1, connected clients: 1
02-27 13:50:00.633 13419-13419/? D/AndroidNative﹕ GameHelper: Pending clients: 0
02-27 13:50:00.633 13419-13419/? D/AndroidNative﹕ GameHelper: All clients now connected. Sign-in successful!
02-27 13:50:00.633 13419-13419/? D/AndroidNative﹕ GameHelper: All requested clients connected. Sign-in succeeded!
02-27 13:50:00.633 13419-13419/? D/AndroidRuntime﹕ Shutting down VM
02-27 13:50:00.633 13419-13419/? W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x415baba8)
02-27 13:50:00.633 13419-13419/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.dokinkon.projectp, PID: 13419
java.lang.Error: FATAL EXCEPTION [main]
Unity version : 4.3.2f1
Device model : LGE Nexus 5
Device fingerprint: google/hammerhead/hammerhead:4.4.2/KOT49H/937116:user/release-keys
Caused by: java.lang.IllegalStateException: No AppStateClient. Did you request it at setup?
at com.google.example.games.basegameutils.GameHelper.getAppStateClient(GameHelper.java:294)
at com.android.gs.GameClientManager.onStateChange(GameClientManager.java:690)
at com.google.example.games.basegameutils.GameHelper.setState(GameHelper.java:272)
at com.google.example.games.basegameutils.GameHelper.succeedSignIn(GameHelper.java:813)
at com.google.example.games.basegameutils.GameHelper.connectNextClient(GameHelper.java:695)
at com.google.example.games.basegameutils.GameHelper.onConnected(GameHelper.java:805)
at com.google.android.gms.internal.k.y(Unknown Source)
at com.google.android.gms.internal.au.y(Unknown Source)
at com.google.android.gms.internal.k$f.a(Unknown Source)
at com.google.android.gms.internal.k$f.a(Unknown Source)
at com.google.android.gms.internal.k$b.D(Unknown Source)
at com.google.android.gms.internal.k$a.handleMessage(Unknown Source)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
I don't know what "java.lang.IllegalStateException: No AppStateClient. Did you request it at setup?" means for. Thanks.
You need to add the APPSTATE client as shown below:
//should be called on your application start
//best practice to call it only once. Any way other calls will be ignored by the plugin.
//if you want to use only Game service (Leader-boards, achievements) use GooglePlayConnection.CLIENT_GAMES
//if you want to use only Google Cloud service use GooglePlayConnection.CLIENT_APPSTATE
//if you want both: GooglePlayConnection.CLIENT_GAMES | GooglePlayConnection.CLIENT_APPSTATE
//and if you whant to get avaliable permissions for your app use: GooglePlayConnection.CLIENT_ALL
GooglePlayConnection.instance.start (GooglePlayConnection.CLIENT_GAMES | GooglePlayConnection.CLIENT_APPSTATE );
Related
Its on an HTC Aria, running 2.2 (API 8)
https://en.wikipedia.org/wiki/HTC_Aria
The aria is an armv6 device that supports opengles 2
If you open up the latest Android Studio (im working on windows 7), then import the HelloGL2 sample, then simply try to run it on the above device, it will fail as soon as it tries to make a call into the native library.
Here is the log:
01-06 11:14:08.467 12771-12813/com.android.gl2jni D/dalvikvm: Trying to load lib /data/data/com.android.gl2jni/lib/libgl2jni.so 0x44c165d0
01-06 11:14:08.467 12771-12813/com.android.gl2jni I/dalvikvm: Unable to dlopen(/data/data/com.android.gl2jni/lib/libgl2jni.so): Cannot load library: link_image[1995]: failed to link libgl2jni.so
01-06 11:14:08.477 12771-12813/com.android.gl2jni W/dalvikvm: Exception Ljava/lang/UnsatisfiedLinkError; thrown during Lcom/android/gl2jni/GL2JNILib;.<clinit>
01-06 11:14:08.497 12771-12813/com.android.gl2jni W/dalvikvm: threadid=8: thread exiting with uncaught exception (group=0x40028a00)
01-06 11:14:08.517 95-121/? I/ActivityManager: Displayed activity com.android.gl2jni/.GL2JNIActivity: 9823 ms (total 2027818 ms)
01-06 11:14:08.567 12771-12813/com.android.gl2jni E/AndroidRuntime: FATAL EXCEPTION: GLThread 9
java.lang.ExceptionInInitializerError
at com.android.gl2jni.GL2JNIView$Renderer.onSurfaceChanged(GL2JNIView.java:332)
at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1327)
at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1118)
Caused by: java.lang.UnsatisfiedLinkError: Library gl2jni not found
at java.lang.Runtime.loadLibrary(Runtime.java:461)
at java.lang.System.loadLibrary(System.java:557)
at com.android.gl2jni.GL2JNILib.<clinit>(GL2JNILib.java:24)
at com.android.gl2jni.GL2JNIView$Renderer.onSurfaceChanged(GL2JNIView.java:332)
at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1327)
at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1118)
01-06 11:14:08.607 95-164/? W/ActivityManager: Force finishing activity com.android.gl2jni/.GL2JNIActivity
This sample works on the 3 other devices i've tried (Galaxy s5, Galaxy J1, Nexus s)
The line: 'Unable to dlopen(/data/data/com.android.gl2jni/lib/libgl2jni.so): Cannot load library: link_image[1995]: failed to link libgl2jni.so' is probably key. I tried loading the library explicitly using system.loadlibrary, but the same problem happens on that call.
I think it might be something to do with the processor being armv6?
The sample is configured to do 'armeabi' though.
I have an Xperia Z3C, Android 5.1.1 and I'm trying to connect it to a Nexus 4 Android 6.0.1 via Bluetooth. Pairing them is OK, but when I try to connect them, it says 'Connected' for less than a second and automatically disconnects.
Is this a known issue? I haven't found anything about this.
Here's what logcat says:
03-14 17:25:55.308: E/bt-btif(14245): bte_scan_filt_param_cfg_evt, 1
03-14 17:25:55.308: E/bt-btif(14245): bte_scan_filt_param_cfg_evt, 1
03-14 17:25:55.990: E/bt-btm(14245): new address: xx:xx:xx:xx:xx:xx
03-14 17:25:55.990: E/bt-btm(14245): new address: xx:xx:xx:xx:xx:xx
03-14 17:25:56.712: E/bt-btm(14245): new address: xx:xx:xx:xx:xx:xx
03-14 17:25:57.464: E/bt-btif(14245): bte_scan_filt_param_cfg_evt, 1
03-14 17:25:57.814: E/bt-btm(14245): Ignoring RNR as the state is not BTM_SEC_STATE_GETTING_NAME
03-14 17:25:57.933: E/NetlinkEvent(318): Unknown ifindex 41 in RTM_DELADDR
03-14 17:25:57.963: E/dhcpcd(15974): bt-pan: interface not found or invalid
03-14 17:25:57.986: E/BluetoothPanServiceJni(14245): ## ERROR : disconnectPanNative(L224): Failed disconnect pan channel, status: 1##
03-14 17:25:58.139: E/BluetoothTetheringNetworkFactory(14245): DHCP request error:DHCP result was failed
03-14 17:26:01.382: E/bt-btm(14245): btm_sec_disconnected - Clearing Pending flag
I had the same problem while trying to scan for Bluetooth devices from my Android application. The interesting thing is that it does not throw any exception (caught or uncaught) and fails silently! The problem occurs for devices with API Level >= 23 (Android 6.0). Here is an extract of my Logcat logs :
03-30 14:07:52.099 192-211/? I/BufferQueueProducer: [org.manios.testbt/org.manios.testbt.printing.BluetoothPrinterDiscovery](this:0x7fa16de400,id:1467,api:1,p:26262,c:192) queueBuffer: fps=0.19 dur=5154.29 max=5154.29 min=5154.29
03-30 14:07:52.114 192-192/? I/SurfaceFlinger: [Built-in Screen (type:0)] fps:1.091767,dur:1831.89,max:999.66,min:832.23
03-30 14:07:52.137 774-1001/? D/InputReader: AP_PROF:AppLaunch_dispatchPtr:Up:89556864, ID:0, Index:2056797440
03-30 14:07:52.137 774-1001/? I/PerfService: PerfServiceNative_boostEnableTimeoutMsAsync:3, 100
03-30 14:07:52.138 26262-26262/org.manios.testbt D/SettingsInterface: from settings cache , name = sound_effects_enabled , value = 0
03-30 14:07:52.138 26262-26262/org.manios.testbt D/BluetoothAdapter: isEnabled
03-30 14:07:52.140 26262-26262/org.manios.testbt D/BluetoothAdapter: getName
03-30 14:07:52.141 774-1636/? D/BluetoothManagerService: checkIfCallerIsForegroundUser: valid=true callingUser=0 parentUser=-10000 foregroundUser=0
03-30 14:07:52.142 21807-21818/? D/BluetoothAdapterProperties: getName: mName = Lenovo TAB3 8
03-30 14:07:52.144 26262-666/org.manios.testbt D/BluetoothAdapter: isEnabled
03-30 14:07:52.146 26262-666/org.manios.testbt D/BluetoothAdapter: isDiscovering
03-30 14:07:52.148 26262-666/org.manios.testbt D/BluetoothAdapter: 109507751: getState(). Returning 12
03-30 14:07:52.152 21807-21817/? D/BluetoothAdapterProperties: isDiscovering: mDiscovering = false
03-30 14:07:52.156 26262-666/org.manios.testbt D/BluetoothAdapter: startDiscovery
03-30 14:07:52.158 26262-666/org.manios.testbt D/BluetoothAdapter: 109507751: getState(). Returning 12
03-30 14:07:52.160 21807-21830/? W/bt_btif: bta_dm_check_av:0
03-30 14:07:52.172 21807-21830/? E/bt_btif: bte_scan_filt_param_cfg_evt, 1
03-30 14:07:52.181 21807-21823/? I/BluetoothAdapterProperties: Callback:discoveryStateChangeCallback with state:1
03-30 14:07:52.182 774-2924/? V/ActivityManager: Broadcast: Intent { act=android.bluetooth.adapter.action.DISCOVERY_STARTED flg=0x10 } ordered=false userid=0 callerApp=ProcessRecord{c376192 21807:com.android.bluetooth/1002}
03-30 14:07:52.184 1057-1265/? V/BluetoothEventManager: Received android.bluetooth.adapter.action.DISCOVERY_STARTED
03-30 14:07:52.185 1057-1265/? D/BluetoothEventManager: scanning state change to true
03-30 14:07:52.186 21983-21983/? D/ActivityThread: BDC-Calling onReceive: intent=Intent { act=android.bluetooth.adapter.action.DISCOVERY_STARTED flg=0x10 cmp=com.android.settings/.bluetooth.BluetoothDiscoveryReceiver }, receiver=com.android.settings.bluetooth.BluetoothDiscoveryReceiver#b02fe63
03-30 14:07:52.186 21983-21983/? V/BluetoothDiscoveryReceiver: Received: android.bluetooth.adapter.action.DISCOVERY_STARTED
03-30 14:07:52.187 21983-21983/? D/ActivityThread: BDC-RECEIVER handled : 0 / ReceiverData{intent=Intent { act=android.bluetooth.adapter.action.DISCOVERY_STARTED flg=0x10 cmp=com.android.settings/.bluetooth.BluetoothDiscoveryReceiver } packageName=com.android.settings resultCode=-1 resultData=null resultExtras=null}
03-30 14:07:52.218 774-1001/? D/InputReader: AP_PROF:AppLaunch_dispatchPtr:Down:89556946, ID:0, Index:2056794048
03-30 14:07:52.219 774-1001/? I/PerfService: PerfServiceNative_boostEnableAsync:3
I found after some searching using this issue, that in API Level >= 23 (Android 6.0) we have to add the following permission to AndroidManifext.xml
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
so that scanning and other Bluetooth actions function properly.
In Android documentation it states in BluetoothAdapter.startDiscovery() that it requires BLUETOOTH_ADMIN permission with no further details. But if we take a look into BluetoothLeScanner.startScan(),it states clearly that:
Requires BLUETOOTH_ADMIN permission. An app must hold ACCESS_COARSE_LOCATION or ACCESS_FINE_LOCATION permission in order to get results.
Hope this helps!
So two things can be going on here. Either the second device that you are trying to maintain a connection with is having an issue maintaining a connection or there is an interference being caused between the two just long enough to break the connection but not long enough to terminate it completely.
LogCat for the GameHelper tag:
06-21 02:39:44.898: D/GameHelper(14315): GameHelper: Debug log enabled.
06-21 02:39:44.898: D/GameHelper(14315): GameHelper: Setup: requested clients: 1
06-21 02:41:59.378: D/GameHelper(19740): GameHelper: Debug log enabled.
06-21 02:41:59.378: D/GameHelper(19740): GameHelper: Setup: requested clients: 1
06-21 02:41:59.473: D/GameHelper(19740): GameHelper: beginUserInitiatedSignIn: resetting attempt count.
06-21 02:41:59.543: D/GameHelper(19740): GameHelper: Starting USER-INITIATED sign-in flow.
06-21 02:41:59.543: D/GameHelper(19740): GameHelper: beginUserInitiatedSignIn: starting new sign-in flow.
06-21 02:41:59.543: D/GameHelper(19740): GameHelper: Starting connection.
06-21 02:42:00.268: D/GameHelper(19740): GameHelper: onConnectionFailed
06-21 02:42:00.268: D/GameHelper(19740): GameHelper: Connection failure:
06-21 02:42:00.268: D/GameHelper(19740): GameHelper: - code: SIGN_IN_REQUIRED(4)
06-21 02:42:00.268: D/GameHelper(19740): GameHelper: - resolvable: true
06-21 02:42:00.268: D/GameHelper(19740): GameHelper: - details: ConnectionResult{statusCode=SIGN_IN_REQUIRED, resolution=PendingIntent{41c25018: android.os.BinderProxy#41c4a710}}
06-21 02:42:00.268: D/GameHelper(19740): GameHelper: onConnectionFailed: WILL resolve because user initiated sign-in.
06-21 02:42:00.268: D/GameHelper(19740): GameHelper: onConnectionFailed: resolving problem...
06-21 02:42:00.268: D/GameHelper(19740): GameHelper: resolveConnectionResult: trying to resolve result: ConnectionResult{statusCode=SIGN_IN_REQUIRED, resolution=PendingIntent{41c25018: android.os.BinderProxy#41c4a710}}
06-21 02:42:00.268: D/GameHelper(19740): GameHelper: Result has resolution. Starting it.
In absence of much context I am guessing that your problem lies with needing to handle the result from the activity that's started in the last log line. That activity handles the login process and returns a result to your own Activity. You need to handle that result yourself. There is an example in the Google Play Games tutorial: https://developers.google.com/games/services/android/init
Search the tutorial page for onActivityResult - you need to override this method in your own Activity as shown in the tutorial example.
Some additional background: when you connect via GoogleApiClient to establish a connection to Google Play Games Services, that API attempts to authenticate the player. When the player is not logged in to the Games Services yet, then the GameHelper starts a new Activity to handle the login process. Once this activity returns, you need to handle the result from the log in.
I currently have a BaseAdapter that is populating a gallery of thumbnails. When an item is visible, an AsyncTask is started from the adapters getView() method to download the thumbnail and when completed the imageview is updated with the correct bitmap. This seems to work really well, except when the user scrolls really fast. This is because of the AsyncTask limitations of holding 128 threads in the queue at any given time.
So my question is how do I properly detect whether the thread pool is full before scheduling another task? Or how do I properly catch the error so I don't receive a force close?
Here are the errors I'm receiving:
5-06 10:54:11.416 27931-27931/com.diverg.tidy E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.diverg.tidy, PID: 27931
java.util.concurrent.RejectedExecutionException: Task android.os.AsyncTask$3#426c4e80 rejected from java.util.concurrent.ThreadPoolExecutor#41bddce0[Running, pool size = 5, active threads = 5, queued tasks = 128, completed tasks = 35]
at java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:2011)
at java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:793)
at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1339)
at android.os.AsyncTask.executeOnExecutor(AsyncTask.java:590)
at com.diverg.tidy.MediaAdapter.getView(MediaAdapter.java:90)
at android.widget.AbsListView.obtainView(AbsListView.java:2263)
at android.widget.GridView.makeAndAddView(GridView.java:1345)
at android.widget.GridView.makeRow(GridView.java:345)
at android.widget.GridView.fillDown(GridView.java:287)
at android.widget.GridView.fillFromTop(GridView.java:421)
at android.widget.GridView.layoutChildren(GridView.java:1233)
at android.widget.AbsListView.onLayout(AbsListView.java:2091)
at android.view.View.layout(View.java:14817)
at android.view.ViewGroup.layout(ViewGroup.java:4631)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1671)
at android.widget.LinearLayout.layoutHorizontal(LinearLayout.java:1660)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1436)
at android.view.View.layout(View.java:14817)
at android.view.ViewGroup.layout(ViewGroup.java:4631)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1671)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1525)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1434)
at android.view.View.layout(View.java:14817)
at android.view.ViewGroup.layout(ViewGroup.java:4631)
at android.widget.ListView.setupChild(ListView.java:1882)
at android.widget.ListView.makeAndAddView(ListView.java:1793)
at android.widget.ListView.fillDown(ListView.java:691)
at android.widget.ListView.fillGap(ListView.java:655)
at android.widget.AbsListView.trackMotionScroll(AbsListView.java:5136)
at android.widget.AbsListView$FlingRunnable.run(AbsListView.java:4247)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761)
at android.view.Choreographer.doCallbacks(Choreographer.java:574)
at android.view.Choreographer.doFrame(Choreographer.java:543)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
05-06 10:54:13.299 29540-29540/? E/dalvikvm﹕ /system/priv-app/GooglePartnerSetup.apk odex has stale dependencies
05-06 10:54:19.346 8024-8024/? E/fb4a(:<default>):AddressResolver﹕ Failed to deserialize to instance com.facebook.mqtt.AddressEntry
at [Source: java.io.StringReader#42180f18; line: 1, column: 34]
05-06 10:54:20.018 125-439/? E/Netd﹕ Failed to write /sys/class/net/rmnet1/mtu: Invalid argument
05-06 10:54:20.025 447-522/? E/ConnectivityService﹕ exception in setMtu()java.lang.IllegalStateException: command '5905 interface setmtu rmnet1 1500' failed with '400 5905 Failed to get MTU (Invalid argument)'
05-06 10:54:20.369 447-1037/? E/ConnectivityService﹕ startUsingNetworkFeature took too long: 330ms
05-06 10:54:20.393 125-439/? E/Netd﹕ Failed to write /sys/class/net/rmnet1/mtu: Invalid argument
05-06 10:54:20.393 447-522/? E/ConnectivityService﹕ exception in setMtu()java.lang.IllegalStateException: command '5917 interface setmtu rmnet1 1500' failed with '400 5917 Failed to get MTU (Invalid argument)'
05-06 10:54:21.439 447-503/? E/WifiStateMachine﹕ Unexpected BatchedScanResults :OK
05-06 10:54:22.096 447-522/? E/ConnectivityService﹕ Unexpected mtu value: android.net.wifi.WifiStateTracker#423a09c0
05-06 10:54:23.932 29936-29936/? E/dalvikvm﹕ /system/priv-app/SetupWizard.apk odex has stale dependencies
05-06 10:54:24.127 29936-29936/? E/PhoneMonitor﹕ onOtaspChanged old =0, new =3
05-06 10:54:24.338 29957-29957/? E/dalvikvm﹕ /system/app/GalleryGoogle.apk odex has stale dependencies
05-06 10:54:25.127 125-439/? E/SecondaryTablController﹕ ip route del failed: /system/bin/ip route del 10.182.14.1/32 via 0.0.0.0 dev rmnet1 table 60
05-06 10:54:25.143 125-439/? E/SecondaryTablController﹕ ip route del failed: /system/bin/ip route del 0.0.0.0/0 via 10.182.14.1 dev rmnet1 table 60
05-06 10:54:25.150 125-439/? E/SecondaryTablController﹕ ip route del failed: /system/bin/ip route del 2600:1014:b10b:6554::1/128 via :: dev rmnet1 table 60
05-06 10:54:25.166 125-439/? E/SecondaryTablController﹕ ip route del failed: /system/bin/ip route del ::/0 via 2600:1014:b10b:6554::1 dev rmnet1 table 60
You can go through documentation of AsyncTask:
http://developer.android.com/reference/android/os/AsyncTask.html
And you can use getStatus() of AsyncTask to know the status of the worker thread. See http://developer.android.com/reference/android/os/AsyncTask.html#getStatus%28%29
I ended up using this as a template. It works by creating a worker thread and adding images to it's queue.
I'm using the HTTPClient library and I'm getting an odd issue where the Socket.close() call never returns causing a TimeoutException. This happens once in a while and I can reproduce it about 10% of the time.
I'm seeing this issue on Android 4.2, 4.3 and 4.4.
Here is the Android Bug Ticket I created for this issue:
http://code.google.com/p/android/issues/detail?id=66102
Any ideas why Socket.close would ever hang forever? How I could avoid this? Thanks!
02-17 20:48:31.800: E/AndroidRuntime(12871): FATAL EXCEPTION: FinalizerWatchdogDaemon
02-17 20:48:31.800: E/AndroidRuntime(12871): Process: com.vblast.sample, PID: 12871
02-17 20:48:31.800: E/AndroidRuntime(12871): java.util.concurrent.TimeoutException: org.apache.http.impl.conn.PoolingHttpClientConnectionManager.finalize() timed out after 10 seconds
02-17 20:48:31.800: E/AndroidRuntime(12871): at libcore.io.Posix.close(Native Method)
02-17 20:48:31.800: E/AndroidRuntime(12871): at libcore.io.BlockGuardOs.close(BlockGuardOs.java:75)
02-17 20:48:31.800: E/AndroidRuntime(12871): at libcore.io.IoBridge.closeSocket(IoBridge.java:188)
02-17 20:48:31.800: E/AndroidRuntime(12871): at java.net.PlainSocketImpl.close(PlainSocketImpl.java:162)
02-17 20:48:31.800: E/AndroidRuntime(12871): at java.net.Socket.close(Socket.java:317)
02-17 20:48:31.800: E/AndroidRuntime(12871): at org.apache.http.impl.BHttpConnectionBase.close(BHttpConnectionBase.java:346)
02-17 20:48:31.800: E/AndroidRuntime(12871): at org.apache.http.impl.conn.LoggingManagedHttpClientConnection.close(LoggingManagedHttpClientConnection.java:83)
02-17 20:48:31.800: E/AndroidRuntime(12871): at org.apache.http.impl.conn.CPoolEntry.closeConnection(CPoolEntry.java:70)
02-17 20:48:31.800: E/AndroidRuntime(12871): at org.apache.http.impl.conn.CPoolEntry.close(CPoolEntry.java:96)
02-17 20:48:31.800: E/AndroidRuntime(12871): at org.apache.http.pool.AbstractConnPool.shutdown(AbstractConnPool.java:127)
02-17 20:48:31.800: E/AndroidRuntime(12871): at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.shutdown(PoolingHttpClientConnectionManager.java:347)
02-17 20:48:31.800: E/AndroidRuntime(12871): at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.finalize(PoolingHttpClientConnectionManager.java:168)
02-17 20:48:31.800: E/AndroidRuntime(12871): at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:187)
02-17 20:48:31.800: E/AndroidRuntime(12871): at java.lang.Daemons$FinalizerDaemon.run(Daemons.java:170)
02-17 20:48:31.800: E/AndroidRuntime(12871): at java.lang.Thread.run(Thread.java:841)
Turns out I confused using Socket.setSoLinger() as my connection timeout setting causing the long hang thus TimeoutException. :/
This is what Socket.setSoLinger() does:
If the socket is in connection-mode, and the SO_LINGER option is set
for the socket with non-zero linger time, and the socket has
untransmitted data, then close() shall block for up to the current
linger interval until all data is transmitted.
http://pubs.opengroup.org/onlinepubs/009695399/functions/close.html
The real issue here is that you have leaked the connection, requiring it to close on finalization. You need to check your code to ensure the closes are in finally blocks. You may also have to call HttpURLConnection.disconnect() yourself.