Wednesday, August 18, 2010

Problem connecting Android to ADB (Android Debug Bridge)

I use the free version of EasySMS a lot - simply because it feels good to write an SMS on the nice browser interface. This way I do not have to take my eyes of the computer screen.

Both the ADB and the EasySMS files was on my Xperia - and with a desktop shortcut in Windows and the Android USB driver installed, my expectation was that I did not need to install the full Android SDK on every PC I get in contact with.

With the USB driver installed, the EasySMS installation on my phone worked fine - for a while. I tested the setup on 3 computers and I thought it was a success.

Then suddenly my script would not open the webinterface - with a sad message that the webpage could not be found. It did not take long to figure out that the problem was the ADB - it could not locate the phone connected.

To make a long storry short:
  • Make sure AdbWinApi.dll is available for adb.exe
  • Make sure AdbWinUsbApi.dll is available for adb.exe
  • Make sure adb.exe is restarted
  • Make sure the phone has the USB Debug connection activated
Somehow the DLL's AdbWinApi.dll and AdbWinUsbApi.dll had disapeared from the directory on the phone where I had adb.exe. After putting the DLL's back, the adb.exe would happily recognize the Xperia attached to the USB port.
Another issue is that the adb deamon running in windows sometimes seems to get "stuck" on a previous connection and won't accept a reconnect. In this case the ADB need a restart. (I read somewhere that the Linux version also have this problem - and on top it needs to have the SUDO command added in front of the adb command to make sure it is performed with root rights):
  • adb kill-server
  • adb start-server
ADB should then return the messages
* daemon not running. starting it now *
* daemon started successfully *

After this, a call to adb devices should show the connected android device, like:
List of devices attached
CB511H16LQ       device