Saturday, March 20, 2010

How to force Eclipse to recognize an Android phone on Ubuntu

When I started developing Android application under Ubuntu, I had the problem, that the phone wasn't recognized by the Android plugin for Eclipse. Luckily there is an easy solution to this!

Simply plug in the phone and then kill and restart the adb server by opening a terminal and executing

sudo ./adb kill-server
sudo ./adb start-server


in your Android-SDK tools directory (e.g. /home/yourname/Android/android-sdk-linux_x86-1.6_r1/tools depending on where you've installed the SDK) as root. Unfortunately you have to enter this workaround only lasts for one session meaning that you have to reenter this after every boot.
I wrote a little bash-script, to make it easier. You can copy'n'paste this from here and save it in a file called restart_adb.sh in a folder named bin in your home directory.

#usr/bin/sh
cd /home/sven/Android/android-sdk-linux_x86-1.6_r1/tools
sudo ./adb kill-server
sudo ./adb start-server
exit 0


This will allow you to simply execute

restart_adb

in your terminal to run it without having to navigate into the sdk's tools directory.

Edit: This is not necessary when using Ubuntu 10.04 which recognizes at least the HTC Hero without any problems.