Search code examples
androidandroid-studioadb

Stopping the Android adb from Android Studio


Background

I'm using Android Studio connected to my phone through usb using the adb (Android Debug Bridge).

The Android Studio seems to recognize that I have connected my phone to the computer, starts the adb, and the device automatically becomes usable through Android Studio.

Issue

When I want to remove my phone, I try to eject the device using "Safely Remove Hardware" feature on Windows.

This, of course, does not work because the adb is still in use. I know how to close the adb in the terminal using adb kill-server (as stated here). However, I'm wondering if there is a way to disconnect it from Android Studio (again, without having to use the terminal view to type adb kill-server).

It seems that if it can automatically connect to the adb there should be an option to disconnect it?

EDIT: This answer suggests closing the adb is not even necessary before removing your phone. If this is true, that is an acceptable response if you can explain why. To me it seems like it would be a problem if you were writing data to the phone at the time of disconnect.


Solution

  • Ejecting is really only needed for devices that have write caching enabled, since in this case the data may still be writing even though the operation has seemingly completed (i.e. the progress dialog says the operation is complete).

    As long as you are sure that ADB is not actively writing to the device, removal without ejection will have no adverse effect whatsoever. Actively reading from the device never has any adverse effect on the file system, since it is not being changed. Usually it is the reading that causes windows to fail at ejecting the device - when running Android Studio, that is generally because it is reading logcat from the device.

    This how-to-geek article provides some decent information on the subject :)