sábado, 15 de março de 2014

Ubuntu 12.04 - Install Android Tools (ADB, Fastboot, ...)


Ubuntu 12.04 - Install Android Tools (ADB, Fastboot, ...)

Contents[Hide]
dropcap-ubuntu-android
If you own an Android Smartphone, you will need sooner or later to use some specific Android tools like adb or fastboot.
If you need these tools, two options are now available under Ubuntu 12.04 :
  • Install the whole Android SDK which bring these tools among may other things
  • Install some specific android-tools packages that bring only these tools
This article will explain the simple steps needed to install Android tools, including latest Android SDK on a Ubuntu Precise 12.04 workstation.
Both options have been tested to Root a Google Nexus S and to Root a Google Nexus 7.

1. Setup ADB Udev Rule

Before accessing your android device in adb mode, you need to :
  • set the device to use USB Debug
  • declare a corresponding Udev rule on your Ubuntu box
After setting the device in USB Debug mode and connecting it to a USB port, throw the command :
# lsusb
...
Bus 002 Device 059: ID 18d1:4e42 Google Inc.
This is the result for a Google Nexus 7 connected in MTP mode with USB Debug on. It gives the Manufacturer and Model ID.
Now that we have these data, we can create the udev rules in /etc/udev/rules.d/99-android.rules.
# sudo gedit /etc/udev/rules.d/99-android.rules
/etc/udev/rules.d/99-android.rules
# Google Nexus 7 16 Gb
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e42", MODE="0666", OWNER="your-login"    # MTP mode with USB debug on
your-login should be your Ubuntu session login.
We can now restart udev for the new rules to become operationnal.
# sudo service udev restart

2. Install Android tools Only

If you don't plan to do some development on your android device, you don't need to install the complete SDK.
One android-tools package is now available on Ubuntu quantal.
Thanks to Web8upd site this package has been ported to Ubuntu precise and is available as a PPA.
So, to install the tools, you just need to declare the PPA and install the package :
# sudo add-apt-repository ppa:nilarimogard/webupd8
# sudo apt-get update
# sudo apt-get install android-tools-adb android-tools-fastboot
The tools are now available in command line.

3. Install Android SDK

3.1. Install Oracle Java 7

To install the complete Android SDK, first step is to install latest Oracle Java 7 runtime environment.
We also have to previously uninstall OpenJDK, as it is provided out of the box with Ubuntu Precise.
Oracle Java is not available in the official Ubuntu repositories anymore because that's not allowed by the new Java license.
We will get the help of WebUpd8 PPA to install it.
The package in the PPA automatically downloads (and installs) Oracle Java JDK 7 from its official website and installs it on the computer (it works like the flashplugin-installer).
# sudo apt-get purge openjdk*
# sudo add-apt-repository ppa:webupd8team/java & sudo apt-get update
# sudo apt-get install oracle-java7-installer

3.2. Install ia32-libs

Android SDK still needs the 32bits compatibility packages to run.
So, if you are running an AMD64 distribution, you need to install the well-known ia32-libs package.
# sudo apt-get install ia32-libs
This will download hundreds of packages and take ages ...

3.3. Install Android SDK

Download Android SDK.
Extract it to one folder & from that folder run these commands :
# cd ./tools
# ./android sdk
Get the default choice and start Install xx packages.
You are now running Android SDK on your Ubuntu box.

4. Allow ADB trusted connexion

Starting from Android 4.2.2 onward, a new security feature has been introduced within ADB.
You must confirm on your device that it is being attached to a trusted computer before any dialog can take place.
This security feature need adb version 1.0.30 and above.
You can check easily your ADB version :
# adb version
Android Debug Bridge version 1.0.31
# adb devices
List of devices attached
xxxxxxxxxxxxxxx          device
If your adb version is too old you'll get :
# adb devices
List of devices attached
xxxxxxxxxxxxxxx          offline
When you will plug your Android device for the first time, it will display a message asking you to allow connexion to your computer as a trusted computer.
You need to validate the message and to select the permanent checkbox.

5. Install QtADB

QtADB is an app based on adb. It requires working  android sdk, Qt libs version 4.7, root and busybox installed on the Android device.
To use QtADB, it is very important to have your device rooted and to have installed Busybox from Google play.
After installation, you need to launch BusyBox Free and start the Install procedure using smart install.
Without these steps, half of QtADB functionalities won't work.

QtADB will allow you to :
  • have a complete access to your Android device filesystem
  • manage your installed applications
  • get some device informations (battery level, memory usage, ...)
  • take some device display screenshot
Before installing it you should install the dependencies :
# sudo apt-get install libqtgui4 libqt4-network libqt4-declarative
Then you need to get QtADB binary from http://qtadb.wordpress.com/download/.
Put the binary QtADB in a directory and make it executable.
The first time you launch it, it will ask for the directory where Android tools are installed (it depends on the fact that you used the PPA or the Google SDK).
You can now access your complete phone filesystem.
Be careful, you have the full powers !
This article is published "as is", without any warranty that it will work for your specific need.
If you think this article needs some complement, or simply if you think it saved you lots of time & trouble,
just let me know at
nicolas.bernaerts@laposte.netThis email address is being protected from spambots. You need JavaScript enabled to view it.
. Cheers !
icon linux icon debian icon apache icon mysql icon php icon piwik icon googleplus