Android SDK and Ubuntu

Ever tried to communicate via command line from an Ubuntu machine to an Android phone connected via the USB port?
Here I write some tips that could facilitate this experience:

- First of all, we need to install the Android SDK in our Ubuntu box. I recommend to follow the Android Developer site. From there, we can download the Android SDK. The steps to have the Android SDK up and running are basically:

Two necessary elements that we need are the ia32-libs (if we have a 64-bit machine) and Java (sun-java6-jdk).

# apt-get install ia32-libs (if your box has a 64-bit processor)
# apt-get install default-jdk (the Java development kit)

Unzip the Android SDK.
Go to the tools folder and run $./android (a graphical configuration page will appear, just press install). It will add a minimum set of packages: tools, platform-tools and at least one (the latest) platform.

Configure the udev file as mentioned in this android page.

And that's about it! To test it, connect your android device via USB and you should be able to see it typing:
# platform-tools/abd devices

- Before focusing on the Android Debug Bridge (adb) tool, a few words on two important elements:
A mechanism to flash (here we mean write to the flash memory) the filesystem in Android devices, e.g. using fastboot (a tool that run with the Android SDK) or flash_image (this last one for a very specific purpose).

Actually this flashing tool will be used to install ClockworkMod (the Rom Manager). A powerful mechanism to, among many things, install new OS, make backups and mount filesystems in Android smartphones.

- adb shell provides a command line shell in the connected device and mounted filesystem (e.g. we can cd to a folder and mv to change file names).
- adb push allows us to copy files from our Ubuntu box to the system folders in the smartphone.

In essence, a Java-based development platform with lots of development potential.

By the way, some additional Android tips:

- Remember a previous Android related post!
- Android 1.x has a very simple file system structure compared to Android 2.x. There will be times when we first have to update to an image of Android 2.x with enough space in each of its partitions before even being able to install ClockworkMod.
- If you receive the following message: ADB: error: insufficient permissions for device then try with these commands as mentioned here:
./adb kill-server
./adb start-server
Now you should be able to run commands like:
./adb devices
./adb shell

- Sometimes you need to install an official image before daring making something with a pre-cooked rom. The way to install official Android images is slightly different and pointed out in this forum: You need to extract the zip file in your computer. Afterwards, copy the entire "dload" folder (resulting out of the decompressing action) into the root folder of the smartphone's SD card.

- Surprise, surprise... Changing an Android firmware could mean that the MAC address of the device changes ;-)!

For those who run out of internal memory, please have a read at the next 4 recommendations:

- If you re-partition the external SD-card, e.g. to make use of apps like Link2sd, after booting with the newly partitioned card, unmount and mount the card (via the android OS) to have access to the apps that were previously installed on the sdcard.

- Regarding re-partitioning an SDcard, my 2 humble cents, 50% space FAT32 and 50%ext2. This leaves the phone ready to use Link2sd.

- The use of App2SD before Link2sd is not recommendable. You would need to re-move the SD'ed apps to the phone memory to be able to use Link2sd, as it says in their FAQ. Link2SD moves not only the .apk file but data, cache and libs (which is a better deal).

- About using Link2sd to move (in Link2SD terms, that is "a link") system apps (like Keyboard, Google Play Store, etc.), just avoid it. 

And finally, remember to use ClockworkMod to create a backup of your phone (and copy the content of your SD cards) right before and after changes.

With all this soup of tools and commands, two security related reflections:
- Android market share could suffer from such a big OS versioning dispersion.
- The Android SDK is a great tool for developers... and hackers ;-)

Happy flashing!

Android or iOS, who will ring the bell?