Search code examples
androidandroid-studioadb

Why can Android Studio not connect to physical devices?


Up until very recently Android Studio had no problems sending APKs to Android devices over USB. But now, although it works fine with the emulator, I cannot send APKs to either of the two physical devices I have tried.

"adb devices" shows no devices connected, even when the phone is connected over a USB cable (I tried other cables too) and when USB debugging IS enabled on the device.

I have tried revoking USB debugging authorisation on the devices, but on restarting adb and reconnecting the device am not asked to authorise the new access.

I've tried rebooting the phones, rebooting the dev machine (a MacBook) and killing and restarting adb, but with no success. I wonder if a recent Android tools update has reset the USB device auth, but how do I re-auth?

It's a problem as the app I'm working on scans barcodes so I really do need a physical device for testing.

UPDATE 1 Ah, so it seems if a USB device is not authorised, it still shows in the list but marked as such. The devices do not show in the list at all so it seems it is not an authorisation issue.

On a Samsung J5, when it is connected to the MacBook, no notification shows. When a Pixel 2 XL is connected to USB, the phone shows the "USB debugging connected" notification, but adb devices does not list it.

UPDATE 2 On making sure adb is running, then connecting both devices to the MacBook with USB and then running "adb devices", I am seeing this:

List of devices attached * daemon not running; starting now at tcp:5037 ADB server didn't ACK Full server startup log: /var/folders/_3/zzf_y_vx2rnc685ysjf1hqr40000gn/T//adb.501.log Server had pid: 13977 --- adb starting (pid 13977) --- adb I 12-08 10:10:52 13977 807310 main.cpp:57] Android Debug Bridge version 1.0.39 adb I 12-08 10:10:52 13977 807310 main.cpp:57] Version 27.0.0-4455170 adb I 12-08 10:10:52 13977 807310 main.cpp:57] Installed as /Users/admin/android-sdk/platform-tools/adb adb I 12-08 10:10:52 13977 807310 main.cpp:57] adb I 12-08 10:10:52 13977 807310 adb_auth_host.cpp:416] adb_auth_init... adb I 12-08 10:10:52 13977 807310 adb_auth_host.cpp:174] read_key_file '/Users/admin/.android/adbkey'... adb F 12-08 10:10:52 13977 807320 transport_usb.cpp:37] Check failed: usb_packet_size < 4096ULL (usb_packet_size=5120, 4096ULL=4096)

  • failed to start daemon error: cannot connect to daemon

If I then use kill-server and start-server, adb fails to start, showing the same output.


Solution

  • This is a bug in the 27.0.0 Android tools, this question has answers that explain solutions, and a link to the bug in the Google bug tracker

    Android Studio - ADB start server fails, adbkey check fails