Friday, September 23, 2011

Getting Ubuntu to play nice with your Android phone

Doing Android app testing on virtual devices isn't really that bad but it aint the good either. It's always much, much better to test that app on a real device.

But Ubuntu (and possible the other *nixs) doesn't recognize your Android phone. You instead get something like this:

$ adb devices
List of devices attached
???????????? no permissions

Unfortunately this is easily fixed. All you have to do is to create a file in the /etc/udev/rules.d directory which contains one (1) line.
Now, what that line is depends on what your phone is. You can figure that one out by using this command:

$ lsusb

And if you haven't connected your phone via the USB before your typed in the command then pat yourself in the back because your are just as brain dead as the rest of the world.
lsusb output
At any rate, you'll notice that my phone is on Bus 002 and the Vendor ID is "0489" and the Product ID is "c000". Remember these values.

Now, lets make the file:
$ sudo gedit /etc/udev/rules.d/51-android.rules
And then, type in the following line: 
SUBSYSTEM=="usb",ATTRS{idVendor}=="0489",ATTRS{idProduct}=="c000",MODE="0666" 
All that's left then is to restart udev. Some devices will require you to disconnect and reconnect them to be recognized.
$ sudo restart udev
To check if your phone is now recognized.
$ adb devices

1 comment: