7

I'm trying to connect adb to my Android device in the Windows 10 Ubuntu shell, but it doesn't seem to be working:

Waiting for Device in Ubuntu Bash Shell

adb does work normally on Windows, so it's not a problem with the phone or the connection. Do I have to do something like mount the port in the Ubuntu shell? How? (The goal is to pass logcat to grep, which would obviously work better in Ubuntu.)

5

There is a tricky way to make it work even with current limitations. You need to start adb server from cmd:

adb kill-server //if it is already running under bash shell
adb start-server

Than you can call adb from bash shell, it will use existing server and as result will be able to list connected devices.

adb devices
  • does this depend on being able to run adb in windows by typing adb directly and not a full path? – Menasheh Nov 7 '16 at 4:56
  • 1
    This doesn't work. I get the following error when attempting to start from cmd and then list from bash.. adb server is out of date. killing... * daemon started successfully * So it looks like from the bash side it's killing and restarting the server. – Byron Aug 26 '17 at 19:52
  • I got this working in Windows 10. I have only adb on Windows installed and adb package on Ubuntu subsystem removed. Start server in Windows, enter bash, go to your adb folder (bash didn't recognize my Windows PATH). adb.exe shell didn't work but adb.exe devices and adb.exe pull works. This is enough for me to use adb with bash scripts. – nikkou Aug 30 '17 at 11:35
  • The trick appears to be that the TCP protocol version of the server and client must match. I found that the major version number of the platform-tools package is equal to 8 less than the protocol version number. On ubuntu, adb 7.0.0+r33-2 complained that it needed protocol version 36, so I downloaded dl.google.com/android/repository/… and it worked. – fuzzyTew Mar 5 '19 at 12:41
  • (sorry, 12 less than the protocol version: as I edited in the answer, I needed platform-tools 24.0.4 for adb 7.0.0+r33-2 on stable ubuntu today) – fuzzyTew Mar 5 '19 at 12:52
4

The bash shell under Windows does not have functions to connect to USB devices. So ADB is not going to work until someone adds that.

Here is the proposal for adding USB support.

  • What does that even mean? Someone = Microsoft or Canonical or both? How do you know this? – Menasheh Sep 18 '16 at 19:03
  • This is actually the support thread for for COM/serial-USB support: wpdev.uservoice.com/forums/…. The one you listed is for drives only. – Afzal Apr 19 '17 at 7:09
  • @Menasheh Microsoft needs to implement this. They wrote the backend that offers devices from Windows. – fuzzyTew Mar 5 '19 at 22:10
3

Adding onto Paul's other answer, you can access the Windows adb server from Ubuntu to resolve this, but it works if and only if the two adb binaries use the same TCP protocol version. For example, adb 7.0.0+r33-2 in Bionic will work with platform-tools 24.0.4 on Windows.

If you have a different version, my first step was just running adb in Windows as he suggests:

> adb kill-server //if it is already running under bash shell
> adb start-server

And then in Ubuntu:

$ adb devices

If the binary protocol versions mismatch, then after running adb in Ubuntu an error is output that gives enough information to get the right binary:

adb server version (40) doesn't match this client (36); killing...

In this example, the server is using protocol version 40, and Ubuntu's package is using version 36. So, one approach is to get a version of adb on Windows that is 4 major releases earlier than the one you have. You can review the platform-tools release notes to find the latest minor version of the needed major version. At the time of this writing, the major version number of platform-tools is 12 lower than the protocol version number of adb, so for protocol version 36 as in this example, we would want platform-tools version 24.0.4 (which is 4 less than 28.0.1, which had protocol version 40). This version number can be used to hand-craft a download url for platform-tools of the needed version.

https://dl.google.com/android/repository/platform-tools_r24.0.4-windows.zip
                         change to correct version here----^

Download and unpack this archive, and rerun adb from cmd:

> adb kill-server
> adb start-server

Now adb will work from Ubuntu.

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.