Geeky interlude: Getting an android device to talk to a linux machine

September 25, 2011 - Geekiness

This post details the steps I had to go through to get my eee-pad transformer Android tablet to talk to a linux machine running Ubuntu for development purposes. In particular, I’m trying to get it to run with AppInventor (a draggy-block-style easy programming environment). There are lots of FAQs and HOWTOs on the net out there, but the straightforward instructions didn’t work for me so I’m putting the things I’ve learned up here, in case someone else can benefit. I’m guessing this post won’t be of interest to you unless you’re trying to mess about with android, running Linux, and haven’t managed to get development set up yet.

1: Get your device so it’s ready for development

This step involves changing settings on the android device (not the computer you’re attaching it to).

  • Under Applications, Development menu, turn on USB debug and Stay awake when charging
  • Under Applications, turn on the setting allowing unknown sources to run code on your device

(Fairly obviously these are security related settings that you probably want to change back once you’re done developing.) That’s all you need to change on the android – everything else involves messing around on the development machine.

2: Install the AppInventor stuff

You can follow the instructions on the Appinventor site for this bit.

2a: Install the Android SDK

I’m not sure if this step is vital – some pages suggested that the appinventor stuff wasn’t enough and you need the full SDK. So I installed it – you can get it from here: Android SDK. The key part seems to be the Android Debug Bridge adb, which does indeed come with AppInventor, but hey, having the full SDK probably doesn’t hurt.

3: Tell your computer about your Android device

This involves using udev, which is the way you tell linux about new devices. Create a file called 51-android.rules with the contents

SUBSYSTEM=="usb", ATTR{idVendor}=="0B05", MODE="0666"

The file should then be moved to the directory /etc/udev/rules.d/, and you’ll need to do that as root. This directory is monitored by udev, so you don’t need to do any more than add the file.

A note: This line is for an ASUS device; if you’re using something other than an ASUS (a HTC or whatever) you’ll have to change 0B05 to the code for your manufacturer. You can look up the codes here.

Another note: The “51-” in the filename is to do with the order in which the devices named in /etc/udev/rules.d are processed; 51 is sort of in the middle of processing order. I’ve read in various places online that you might need a higher number (i.e. you might need to mount your android device last), so if none of this crap works, try renaming the file to 99-android.rules.

4: Check that the device is now visible by adb

Go to the android SDK directory (or the appinventor directory if you’ve not installed the whole SDK). In the platform-tools subdirectory is adb, the “android debug bridge”. This is a client-server application that listens out for android devices. Type

./adb devices

If you see your device (there’s an ID number of a device) brilliant, it’s all worked. If you don’t, try killing the adb server using

./adb kill-server

and then try restarting the server as root

sudo ./adb start-server

This was the final key to my puzzle (in particular, running the adb server as root seemed to fix it for me), and I now have development apps on the screen of my eee pad. Let me know if it works for you.

› tags: adb / android / appinventor / eee / eeepad / geek / Geekiness / linux / ubuntu / udev /

Leave a Reply

Your email address will not be published. Required fields are marked *