4

I've been suffering through this for a couple weeks now, hoping that an update would fix it, but now I don't know who to turn to. So, I develop apps for android and iOS. Typically I just test on my own phone, which is a Galaxy S7 Edge. When I got it, I looked up how to access developer mode and did that. I then turned on USB debugging, however, when I hooked up my phone, my Android Studio could not find the device.

I looked at my options under the "Use USB for..." menu and picked 'Software installation'. My Android Studio found my device and I started using it to test apps. It worked great, so I didn't ask any questions, until a couple weeks ago, after a security update I started getting a weird error. Every time I was connected to my computer and I set my usb mode to Software installation, after about 30 seconds it would change to File Transfer mode on its own.

I cannot be in Software installation mode for more than a minute at any given time, and when I am in File Transfer mode, my Android Studio won't register my phone as a debugging device. I downloaded the most recent update today, but that didn't fix my issue. I Googled the issue, but I can't find anyone who seems to have had this problem. Has anyone had this problem? Does anyone have a clue how to fix it?

Tl;dr: My phone cannot stay in Software installation mode long enough for me to download an app from Android Studio to test. I'm using 6.0.1

1
+25

Sorry, not an answer but rather some information, too much to put into comments. perhaps this could help someone determine what could be hapening.

Scenario Windows 7, AS 2.1.2, Genymotion 2.8 (but initially using a 2.6 device API 22). Working fine for a few hours (actually a bit of a lie as had tablet plugged in as well but need to start somewhere in the viscous circle). Started ADM (Android Device Monitor) (better/easier feedback). Still OK (i.e just genymotion device visible).

1) Plugin in Lenovo A10-30 API 24 with MTP enabled but NOT USB Debug. All fine.

2) Switch to charging. No change in AS or ADM.

3) Turn on USB Debug. Immediately disconnects Genymotion Device and tries but fails to connect tablet (and less frequently, I think the Genymotion device). Log ADM extract :-

[2016-10-27 13:47:19 - DeviceMonitor] Adb connection Error:An existing connection was forcibly closed by the remote host
[2016-10-27 13:47:20 - DeviceMonitor] Connection attempts: 1
[2016-10-27 13:47:21 - DeviceMonitor] Adb connection Error:An existing connection was forcibly closed by the remote host
[2016-10-27 13:47:22 - DeviceMonitor] Connection attempts: 1
[2016-10-27 13:47:24 - DeviceMonitor] Connection attempts: 2
[2016-10-27 13:47:27 - DeviceMonitor] Adb connection Error:An existing connection was forcibly closed by the remote host
[2016-10-27 13:47:28 - DeviceMonitor] Connection attempts: 1
[2016-10-27 13:47:30 - DeviceMonitor] Adb connection Error:An existing connection was forcibly closed by the remote host
[2016-10-27 13:47:31 - DeviceMonitor] Connection attempts: 1
[2016-10-27 13:47:32 - DeviceMonitor] Adb connection Error:An existing connection was forcibly closed by the remote host
[2016-10-27 13:47:33 - DeviceMonitor] Connection attempts: 1
[2016-10-27 13:47:35 - DeviceMonitor] Adb connection Error:An existing connection was forcibly closed by the remote host
[2016-10-27 13:47:36 - DeviceMonitor] Connection attempts: 1
[2016-10-27 13:47:38 - DeviceMonitor] Adb connection Error:An existing connection was forcibly closed by the remote host
[2016-10-27 13:47:39 - DeviceMonitor] Connection attempts: 1
[2016-10-27 13:47:40 - DeviceMonitor] Adb connection Error:An existing connection was forcibly closed by the remote host
[2016-10-27 13:47:41 - DeviceMonitor] Connection attempts: 1
[2016-10-27 13:47:43 - DeviceMonitor] Adb connection Error:An existing connection was forcibly closed by the remote host
[2016-10-27 13:47:45 - DeviceMonitor] Connection attempts: 1
[2016-10-27 13:47:46 - DeviceMonitor] Adb connection Error:An existing connection was forcibly closed by the remote host
[2016-10-27 13:47:47 - DeviceMonitor] Connection attempts: 1
[2016-10-27 13:47:49 - DeviceMonitor] Connection attempts: 2

Adroid Monitor in AS shows the following message frequently (Genymotion devices shows Disconnected) :-

01-01 00:00:00.000 0-0/? E/Internal: An existing connection was forcibly closed by the remote host

4) After about 5 minutes turn USB Debug off on Tablet.

Aprrox 3 minutes later, after :-

[2016-10-27 13:54:07 - DeviceMonitor] Adb connection Error:An existing connection was forcibly closed by the remote host
[2016-10-27 13:54:08 - DeviceMonitor] Connection attempts: 1

Genymotion device is now re-connected.


6) Turn MTP on (File Transfers on on Tablet), USB Debug still off.

Other than the windows dialog, nothing changes (AS and ADM show Genymotion device as connected).

7) Turn USB Debug on on the Tablet (from developer options)

Basically the same happens again. So I stop USB debug on Tablet and wait.

8) Revoke USB debugging authorisation on the Tablet and try USB Debug again. Allow it always.

Same Again. So stop USB Debug on Tablet and wait another 3 minutes or so for the Genymotion device to reconnect.

9) Stop the Genymotion device. So nothing is connected.

10) Turn USB Debug on on the Tablet. Tablet connects OK.

11) Start Genymotion device connects OK and tablet still connected.

12) Plug in an an HTC Sensation XL (Android 4.0.3) same again but disconnects both the Tablet and the Genymotion device. Disconnect the HTC phone and wait the obligatory 3 minutes or so. Both reconnect.

13) Stop the Genymotion device (tablet still connected) and try connecting the HTC phone. HTC phone connects and the Tablet remains connected.

14) Start the Genymotion device, it connects and the other 2 (Tablet and Phone) remain connected.

A thought, is it due to the Genymotion virtual device? Perhaps a virtual device must be the last to be connected. Perhaps you may be using an AVD if so perhaps try disabling that and see what happens (I can't use AVD I think due to having an AMD chip).

Updated 23/11/2016 In brief I don't think that Genymotion is the issue but perhaps Android Studio.

Today I purchased another Tablet, an Onix 10.1 Quad Core. Pretty similar spec to the Lenovo. The main difference being a smaller screen (1024x600).

However, I have been experiencing similar issues connecting to it. That is the dreaded "An existing connection was forcibly closed by the remote host".

It appears to be even harder to get connected than the Genymotion devices.

My last successful attempt was made after numerous failed attempts and was when I closed and then restarted Android Studio. Hence why I now suspect that AS is perhaps the cause. If I look into this further I may update this with my findings.

  • While this is similar to what is happening to me, it is actually not the same. My device is connecting to the computer, it just isn't considered a connected device to Android Studio. Also, I was in USB debugging mode with a successful connection to Android studio for weeks before this started to happen. – EvSunWoodard Oct 27 '16 at 13:34
  • That aspect i.e. the devices connecting to the computer is the same, they all connect. It is from Android Studio's aspect that I reported disconnects. I went through various modes debug/ no debug to try to isolate the issue I have (which is very similar to yours other than I can get around it) more in next comment..... – MikeT Oct 27 '16 at 19:02
  • The main difference is that I use a virtual/emulated device(s) (via Genymotion) not the AS virtual devices. It appears that the virtual device I use is central to the issue I have. More specifically connecting another real device after the virtual device. My thought is that perhaps Android Studio's virtual devices do the same/similar. I suggest trying to eliminate this as a factor by ensuring that you don't have any virtual devices. Tools/Android/Android Device Monitor can be used for this. If you do then Tools/Android/AVD Manager would be the likely place to stop/disable them. – MikeT Oct 27 '16 at 19:33
1

I had this error on my Verizon S7. The fix was to go to applications, and force stop KNOX. This allowed me to use adb from regular file transfer.

  • This should be the accepted answer. And not only because it's the only actual answer that's been posted, but because this is the secret sauce that actually works. – Sensei James Oct 18 '17 at 14:33
0

When you say you're setting the mode under "Use USB For", do you mean the one that should show up as a notification, or the one in Developer Options?

If you mean the notification, check the one in Developer Options, in stock Android, there's an option in the Networking subsection labeled "Select USB Configuration"

  • After testing the "USB configuration" in developer options, this didn't fix the problem. There is no Software installation configuration in dev options. There are: charging, MTP, PTP, RNDIS, Audio Source, and MIDI. When I select Software Installation on the notification option screen, it sets the dev option setting to charging. Then the when the phone forces to MTP, it changes both the notification option and the Dev option screen at the same time. It changes them both to MTP. – EvSunWoodard Oct 24 '16 at 14:00
  • I have a similar issue. I have a Lenovo tablet and two HTC phones plus I use Genymotion (emulator). Often plugging one in messes itself and the others up (repeated disconnects stays on for less than a second, console says something like forced disconnect). Sometimes resetting the authroisations fixes things (I think I get to that option from the notifications). Earlier today I went into sync options in Genymotion device and that fixed it. To me it feels like it's conflicts with the usb drivers. Using Genymotion on it's own for development is reliable for me. – MikeT Oct 26 '16 at 10:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.