Android Tutorial Connecting your device to the IDE

Introduction

A program called adb.exe - Android Debug Bridge - is the key component that is used to communicate between programs on your desktop and the emulator or device. adb can be invoked without user intervention by programs such as Basic4Android and Eclipse but also has a command line interface that can be used by advanced users. adb.exe is provided with the Android SDK and is located, together with other development tools, on early versions of the Android SDK in the <android-sdk-windows>\tools and on more recent versions in the <android-sdk-windows>\platform-tools folder. Unless adb can connect properly to the emulator or device Basic4Android will not be able to load and run applications, however in this event they could still be compiled then copied to the SD card on the device by USB and installed from there. This tutorial tries to explain how to get your device connected to adb so that you can use it with the Basic4Android IDE.


Device SD cards and USB

Although this capability is entirely independent of adb it is worth including here for completeness in describing how devices use USB connections. Android devices have a USB port that when plugged into a desktop lets the SD card on the device look like a USB memory stick. The first time that a device is connected to a desktop by USB Windows should automatically detect this and install the necessary driver without you having to do anything. The SD card will then appear as a disc drive in Windows Explorer and Device Manager while the device is connected. While the SD card is visible to the desktop as a drive the device will not be able to access it as it is unmounted from the device. Some, but not all, devices allow you to mount and unmount the SD card from the device when it is plugged into the desktop USB. Other devices do not offer this option but automatically unmount it on connection to USB and remount it on disconnection. You will have to see how your own device behaves in this regard


The emulator and adb

There should be absolutely no problem using the emulator with Basic4Android. adb will connect automatically and should work well, although I have found that if the emulator is running Android 1.6 the adb connection will frequently drop and cause problems. Therefore I recommend using Android 2.1 or later in the emulator to avoid any possible problems. Also there should be no problem interacting with the emulator with adb in command line mode if that is required. Because the emulator should just work the remainder of this article deals with connecting devices by means of adb.


Devices and adb

In my experience so far devices differ in their USB capability and in their interaction with adb and Windows so the following can only be a guide. Your experience may vary.

adb can connect a device to the desktop by two different means, Wi-Fi and USB. In both cases for adb to recognise the device Settings -> Applications -> Development -> USB debugging must be checked. This runs the adb daemon on the device which communicates with adb on the desktop.


adb and WiFi

To connect to a device wirelessly you need to connect the device to the network by Wi-Fi and obtain the device IP address. This can be found under Settings -> Wireless & Networks -> Wi-Fi Settings. Press the connected network under the WiFi Networks section and a message box will display the connection details.

Before running Basic4Android open a Command Window in the <android-sdk-windows>\tools folder and type the command

adb connect 192.168.0.10

replacing the IP address with the correct one for the device.

if you get an error try specifying the port

adb connect 192.168.0.10:5555

I have encountered only partial functionality with adb over Wi-Fi. I have a tablet that works fine with adb and so with Basic4Android - which is just as well as the tablet lacks the USB connectivity needed for adb. I also have a phone that mostly works with adb in command line mode but adb hangs and doesn't return to the command prompt after performing an install or uninstall although the actual operation on the device is successful. This behaviour means that neither Basic4Android nor Eclipse can be used with the phone over wireless but thankfully they work perfectly over USB.


adb and USB

Many Android devices, but not all like some cheap Chinese Android tablets, have two more USB interfaces "Android ADB Interface" and "Android Composite ADB Interface". These belong to a device that, on successful USB driver installation, appears as "Android Phone" in Device Manager and is used by adb to connect to the phone over USB. If your phone lacks these it may still be possible to connect adb to it by means of wireless as described above.

These Android interfaces, unlike SD card access, need custom USB drivers that are located in the <android-sdk-windows>\usb_driver. In this folder there is a android_winusb.inf file that contains the USB IDs needed to install the drivers for different phones. When a phone is connected and Windows asks for the drivers for this device point it to this folder. If the drivers then fail to install it is likely that the android_winusb.inf does not contain the IDs for the phone. In android_winusb.inf there are two sections the one named [Google.NTx86] contains the details for 32 bit systems, another named [Google.NTamd64] contains the details for 64 bit systems. The two sections are in fact identical. For my phone to be recognised the following details needed to be inserted in each of the two sections mentioned.

;Orange San Francisco
%SingleAdbInterface% = USB_Install, USB\VID_19D2&PID_1354&MI_00
%CompositeAdbInterface% = USB_Install, USB\VID_19D2&PID_1354&MI_02

These necessary details were obtained courtesy of a certain well known Internet search engine. However, rather belatedly, Google now at last has a list of links to manufacturer sites that provide USB drivers for their devices on this page Google USB Driver . The actual link is OEM USB Drivers.

Note that for some devices, like my phone, Windows may try to install the drivers without USB Debugging being enabled on the phone. This is likely to fail even when you point Windows at the drivers that installed successfully with USB Debugging enabled. As this will happen every time the phone is plugged in to USB the solution is to keep USB Debugging enabled. This has no downside as, for this phone at least, the USB access to the SD card is entirely independent of whether USB Debugging is enabled or not.

More on adb and WiFi

Some devices seem to not have the adb daemon enabled for wireless. There is an application called adbWireless that can overcome this for many, but not all, devices. It is available on the Android Market, the latest version is 1.4.1, but it needs root access to the phone to work.

Another application called UniversalAndroot may help here - it worked on my ZTE Blade/Orange SanFrancisco to let me run adbWireless on it. It can be downloaded from universalandroot by clicking one of the links at the bottom of the page by the 2D barcodes.
 
Last edited:

dbower

New Member
Licensed User
Longtime User
When connecting the new Verizon Galaxy Nexus, you must download and install the USB Driver from the Samsung Site:

Samsung

Once I installed the driver and restarted Basic4Android, I was able to connect to the galaxy. The USB Drivers in the Android API dowload would NOT Work.
 

gareththomasnz

Member
Licensed User
Longtime User
The google driver will connect to pretty much any device but you have to recode it with your devices hardware PID or VID number

Every USB device has two codes that help distinguish it from other USB devices that a host may encounter: the Vendor ID (VID) and Product ID (PID). A VID/PID unique to a particular USB device must be contained within the device hardware to comply with the USB specification

http://visualgdb.com/tutorials/android/usbdebug/manualinstall.php

http://stackoverflow.com/questions/9709263/google-android-usb-driver-and-adb

I will add that all I normally have to do is add the PID & VID to the ini file in the correct places

I have done this with two different chinese tablets that had no driver & it works perfectly - nothing else was required just four extra lines in the ini - then install the driver
 
Last edited:
Top