Search

Ubuntu 16.04 LTS - Install Android Tools (ADB, Fastboot & QtADB)

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 available under Ubuntu : either to install the whole Android SDK or to install some specific packages that bring only these tools.

Another very insteresting tool is QtADB. Based on ADB protocol, it allows under a graphical interface to have a complete access to your Android device filesystem, to manage your installed applications, to get some system informations, ...

As most of Android smartphone or tablet users are not needing the whole Android SDK, this article explains the simple steps needed to install Android specific tools like ADB, fastboot or QtADB on a Ubuntu computer.

It has been tested under Ubuntu Xenial 16.04 LTS and it has been used to flash and root a Google Nexus 5 & OnePlusX under LineageOS, a OnePlus 3 under OxygenOS and few other old devices. It should be applicable with any modern Linux distro.

1. Install Android tools

If you don't plan to do some development on your android device, you don't need to install the complete SDK.

Two android-tools packages are now available for Ubuntu. They provide a minimal set of tools like adb and fastboot.

These tools are exactly what you need to root your phone, to flash a ROM, to sideload an application, ...

As these packages are now in Ubuntu official repositories, is has become very easy to install these packages :

Terminal
# sudo apt-get install android-tools-adb android-tools-fastboot

2. Update to latest ADB and fastboot

Under Xenial official repositories, ADB and fastobbot versions are quite old (version 1.0.32).

Hopefully, since January 2017, Google has started to officially provide Linux Platform Tools binaries that your can install on top of official Ubuntu version.

You need to install Google latest ADB and fastboot tools and then to declare a launcher under /usr/local/sbin.

Latest version will then be used instead of Ubuntu stock versions.

This can be done easily with these commands :

Terminal
# adb version
Android Debug Bridge version 1.0.32
# wget https://dl.google.com/android/repository/platform-tools-latest-linux.zip
# sudo unzip -d /usr/local/sbin platform-tools-latest-linux.zip
# sudo wget -O /usr/local/sbin/adb https://raw.githubusercontent.com/NicolasBernaerts/ubuntu-scripts/master/android/adb
# sudo wget -O /usr/local/sbin/fastboot https://raw.githubusercontent.com/NicolasBernaerts/ubuntu-scripts/master/android/fastboot
# sudo chmod +x /usr/local/sbin/adb /usr/local/sbin/fastboot
# adb version
Android Debug Bridge version 1.0.39
Revision 3db08f2c6889-android
Installed as /usr/local/sbin/platform-tools/adb

You now have latest ADB version which will allow you to handle latest Android devices.

3. Declare Vendor ID for ADB

To be detected as an ADB device, your device vendor ID should be known. Most manufacturers vendor ID are pre-declared, but some may be missing.

You can add your Vendor ID in ~/.android/adb_usb.ini

~/.android/adb_usb.ini
# Android 3rd party USB Vendor ID list
# Needed to access exotic vendors devices thru ADB

# Archos
0x0e79
# BQ
0x2a47
# Genesys
0xd324
# OnePlus
0x2a70
# Xiaomi
0x2717
# Zebra
0x0451
0x05e0

You can download this file from my GitHub repository.

Terminal
# wget -O $HOME/.android/adb_usb.ini https://raw.githubusercontent.com/NicolasBernaerts/ubuntu-scripts/master/android/adb_usb.ini

If your device Vendor ID is not recognised and needs to be added to this file, just let me know or submit it thru GitHub, I'll add it.

4. 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 :

Terminal
# lsusb
...
Bus 001 Device 119: ID 2a70:9011

This is the result for a OnePlus 3 connected in MTP mode with USB Debug on. It gives  :

  • the Manufacturer ID
  • the Model ID.

To be on the safe side, we will declare some generic rules for main Android phones manufacturers.

These rules will be declared /etc/udev/rules.d/51-android.rules.

/etc/udev/rules.d/51-android.rules
# udev rule to detect android devices
# These rules refer to http://developer.android.com/tools/device.html

# Acer
SUBSYSTEM=="usb", ATTR{idVendor}=="0502", MODE="0666", GROUP="plugdev"
# Archos
SUBSYSTEM=="usb", ATTR{idVendor}=="0e79", MODE="0666", GROUP="plugdev"
# Asus
SUBSYSTEM=="usb", ATTR{idVendor}=="0b05", MODE="0666", GROUP="plugdev"
# Azpen Onda
SUBSYSTEM=="usb", ATTR{idVendor}=="1f3a", MODE="0666", GROUP="plugdev"
# BQ
SUBSYSTEM=="usb", ATTR{idVendor}=="2a47", MODE="0666", GROUP="plugdev"
# Dell
SUBSYSTEM=="usb", ATTR{idVendor}=="413c", MODE="0666", GROUP="plugdev"
# Fairphone
SUBSYSTEM=="usb", ATTR{idVendor}=="2ae5", MODE="0666", GROUP="plugdev"
# Foxconn
SUBSYSTEM=="usb", ATTR{idVendor}=="0489", MODE="0666", GROUP="plugdev"
# Fujitsu Toshiba 
SUBSYSTEM=="usb", ATTR{idVendor}=="04c5", MODE="0666", GROUP="plugdev"
# Garmin-Asus
SUBSYSTEM=="usb", ATTR{idVendor}=="091e", MODE="0666", GROUP="plugdev"
# Genesys
SUBSYSTEM=="usb", ATTR{idVendor}=="d324", MODE="0666", GROUP="plugdev"
# Google
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", MODE="0666", GROUP="plugdev"
# Haier
SUBSYSTEM=="usb", ATTR{idVendor}=="201e", MODE="0666", GROUP="plugdev"
# Hisense
SUBSYSTEM=="usb", ATTR{idVendor}=="109b", MODE="0666", GROUP="plugdev"
# HTC, Wiko
SUBSYSTEM=="usb", ATTR{idVendor}=="0bb4", MODE="0666", GROUP="plugdev"
# Huawei
SUBSYSTEM=="usb", ATTR{idVendor}=="12d1", MODE="0666", GROUP="plugdev"
# Intel
SUBSYSTEM=="usb", ATTR{idVendor}=="8087", MODE="0666", GROUP="plugdev"
# K-Touch
SUBSYSTEM=="usb", ATTR{idVendor}=="24e3", MODE="0666", GROUP="plugdev"
# KT Tech
SUBSYSTEM=="usb", ATTR{idVendor}=="2116", MODE="0666", GROUP="plugdev"
# Kyocera
SUBSYSTEM=="usb", ATTR{idVendor}=="0482", MODE="0666", GROUP="plugdev"
# Lab126
SUBSYSTEM=="usb", ATTR{idVendor}=="1949", MODE="0666", GROUP="plugdev"
# Lenovo
SUBSYSTEM=="usb", ATTR{idVendor}=="17ef", MODE="0666", GROUP="plugdev"
# LG
SUBSYSTEM=="usb", ATTR{idVendor}=="1004", MODE="0666", GROUP="plugdev"
# Meizu
SUBSYSTEM=="usb", ATTR{idVendor}=="2a45", MODE="0666", GROUP="plugdev"
# Micromax
SUBSYSTEM=="usb", ATTR{idVendor}=="1ebf", MODE="0666", GROUP="plugdev"
# Motorola
SUBSYSTEM=="usb", ATTR{idVendor}=="22b8", MODE="0666", GROUP="plugdev"
# MTK
SUBSYSTEM=="usb", ATTR{idVendor}=="0e8d", MODE="0666", GROUP="plugdev"
# NEC
SUBSYSTEM=="usb", ATTR{idVendor}=="0409", MODE="0666", GROUP="plugdev"
# Nook
SUBSYSTEM=="usb", ATTR{idVendor}=="2080", MODE="0666", GROUP="plugdev"
# Nvidia
SUBSYSTEM=="usb", ATTR{idVendor}=="0955", MODE="0666", GROUP="plugdev"
# OnePlus Two (unknown vendor's name)
SUBSYSTEM=="usb", ATTR{idVendor}=="2a70", MODE="0666", GROUP="plugdev"
# Oppo
SUBSYSTEM=="usb", ATTR{idVendor}=="22d9", MODE="0666", GROUP="plugdev"
# OTGV
SUBSYSTEM=="usb", ATTR{idVendor}=="2257", MODE="0666", GROUP="plugdev"
# Pantech
SUBSYSTEM=="usb", ATTR{idVendor}=="10a9", MODE="0666", GROUP="plugdev"
# Pegatron
SUBSYSTEM=="usb", ATTR{idVendor}=="1d4d", MODE="0666", GROUP="plugdev"
# Philips
SUBSYSTEM=="usb", ATTR{idVendor}=="0471", MODE="0666", GROUP="plugdev"
# PMC-Sierra
SUBSYSTEM=="usb", ATTR{idVendor}=="04da", MODE="0666", GROUP="plugdev"
# Qualcomm
SUBSYSTEM=="usb", ATTR{idVendor}=="05c6", MODE="0666", GROUP="plugdev"
# Rockcwell Electronics
SUBSYSTEM=="usb", ATTR{idVendor}=="2207", MODE="0666", GROUP="plugdev"
# SK Telesys
SUBSYSTEM=="usb", ATTR{idVendor}=="1f53", MODE="0666", GROUP="plugdev"
# Samsung
SUBSYSTEM=="usb", ATTR{idVendor}=="04e8", MODE="0666", GROUP="plugdev"
# Sharp
SUBSYSTEM=="usb", ATTR{idVendor}=="04dd", MODE="0666", GROUP="plugdev"
# Sony
SUBSYSTEM=="usb", ATTR{idVendor}=="054c", MODE="0666", GROUP="plugdev"
# Sony Ericsson
SUBSYSTEM=="usb", ATTR{idVendor}=="0fce", MODE="0666", GROUP="plugdev"
# Spreadtrum
SUBSYSTEM=="usb", ATTR{idVendor}=="1782", MODE="0666", GROUP="plugdev"
# T & A Mobile Phones
SUBSYSTEM=="usb", ATTR{idVendor}=="1bbb", MODE="0666", GROUP="plugdev"
# Teleepoch
SUBSYSTEM=="usb", ATTR{idVendor}=="2340", MODE="0666", GROUP="plugdev"
# Texas Instruments UsbBoot
SUBSYSTEM=="usb", ATTR{idVendor}=="0451", MODE="0666", GROUP="plugdev"
# Toshiba
SUBSYSTEM=="usb", ATTR{idVendor}=="0930", MODE="0666", GROUP="plugdev"
# Wearners
SUBSYSTEM=="usb", ATTR{idVendor}=="05c6", MODE="0666", GROUP="plugdev"
# Wileyfox
SUBSYSTEM=="usb", ATTR{idVendor}=="2970", MODE="0666", GROUP="plugdev"
# XiaoMi
SUBSYSTEM=="usb", ATTR{idVendor}=="2717", MODE="0666", GROUP="plugdev"
# YU
SUBSYSTEM=="usb", ATTR{idVendor}=="1ebf", MODE="0666", GROUP="plugdev"
# Zebra
SUBSYSTEM=="usb", ATTR{idVendor}=="05e0", MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", ATTR{idVendor}=="0451", MODE="0666", GROUP="plugdev"
# ZTE
SUBSYSTEM=="usb", ATTR{idVendor}=="19d2", MODE="0666", GROUP="plugdev"
# ZUK
SUBSYSTEM=="usb", ATTR{idVendor}=="2b4c", MODE="0666", GROUP="plugdev"

Terminal
# sudo wget -O /etc/udev/rules.d/51-android.rules https://raw.githubusercontent.com/NicolasBernaerts/ubuntu-scripts/master/android/51-android.rules
# sudo chmod a+r /etc/udev/rules.d/51-android.rules

We can now restart udev for the new rules to become operationnal.

Terminal
# sudo service udev restart

5. Allow ADB trusted connexion

Starting from Android 4.2.2 onward, you must confirm on your device that it is being attached to a trusted computer before any dialog can take place.

If you've not authorized the connexion, you'll get an unauthorized message :

Terminal
# adb devices
List of devices attached
da16db7b      unauthorized

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.

Terminal
# adb devices
List of devices attached
da16db7b      device

Your Android device is now fully accessible thru ADB.

6. If your device is not detected ...

If everything is ready

  • ADB installed on the computer
  • ADB enabled in the developper mode menu of your device

and your device is not detected by your computer, you may be facing the USB3 bug.

On modern computer, most of the USB ports are USB3 and there is an incompatibility between some Android devices and USB3 ports. 

This problem must be software related, as one of my phone is not recognized thru adb but is fully recognized thru fastboot on the same USB port !

The easiest way to solve it is damn simple : just connect a cheap, self-powered USB hub between your computer and your Android device. 

7. Install QtADB

android-qtadb

QtADB is a powerful graphical Android device manager based on ADB protocol.

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

7.1. Prerequisite on Phone or Tablet Side

To be able to fully use QtADB with your phone or tablet, the device needs to :

  • be rooted
  • have busybox installed (without busybox installed, half of QtADB functionalities won't work)

If your phone is running LineageOS, you should allow root access for ADB.

You can test your phone configuration with the following command from your computer :

Terminal
# adb shell busybox ls -l -a
rwxr-xr-x 20 root root 0 Nov 22 1970 .
drwxr-xr-x 20 root root 0 Nov 22 1970 ..
d--------- 2 root root 0 Jan 1 1970 .subackup
drwxr-xr-x 70 root root 0 Nov 22 1970 acct
lrwxrwxrwx 1 root root 50 Jan 1 1970 bugreports -> /data/user_de/0/com.android.shell/files/bugreports
drwxrwx--- 6 system cache 4096 Nov 21 1970 cache
...

7.2. Installation

QtADB requires :

  • a working ADB installation (done previously)
  • Qt libs version 4.7

First step is to install the dependencies. You can then download executable from the site download section and install it.

Select the download package according to your distribution (32bits i386 or 64bits Amd64).

Terminal
# sudo apt-get -y install libqtgui4 libqt4-network libqt4-declarative
# wget -O qtadb.tar.gz http://motyczko.pl/qtadb/QtADB_0.8.1_linux64.tar.gz
# tar -xvf qtadb.tar.gz
# sudo mv ./QtADB*/QtADB /usr/local/sbin/qtadb
# sudo chmod +x /usr/local/sbin/qtadb
# rm qtadb.tar.gz
# rm -R QtADB*

QtADB is now installed on your computer.

7.3. Get Rid of the Startup Crash Bug

Version 0.8+ of QtADB is subject to a very nasty bug.

When you launch it, some internet update verification process makes it crash. 

Terminal
 # qtadb
Segmentation fault (core dumped)

As this update verification is set by default, we need to disable it.

This is done easily by creating the default QtADB.conf configuration file that disables the CheckForUpdateOnStart key :

Terminal
# mkdir --parents $HOME/.config/Bracia
# wget $HOME/.config/Bracia/QtADB.conf https://raw.githubusercontent.com/NicolasBernaerts/ubuntu-scripts/master/android/QtADB.conf

~/.config/Bracia/QtADB.conf
[General]
sdkPath=/usr/local/sbin/
checkForUpdatesOnStart=false

QtADB should now stop to crash at startup.

7.4. Create Application Launcher

Last step is to declare the application to be used by your desktop launcher..

This is done by downloading an application icon and by creating a qtadb.desktop file :

Terminal
# sudo wget -O /usr/share/icons/qtadb.png https://github.com/NicolasBernaerts/ubuntu-scripts/raw/master/android/qtadb.png
# sudo wget -O /usr/share/applications/qtadb.desktop https://raw.githubusercontent.com/NicolasBernaerts/ubuntu-scripts/master/android/qtadb.desktop

/usr/share/applications/qtadb.desktop
[Desktop Entry]
Encoding=UTF-8
Name=QtADB
Exec=qtadb
Icon=qtadb
Type=Application
Categories=Utility;

You can now launch QtADB and your Android phone filesystem should now fully accessible.

For example, your can take full screenshot of your phone display in one click.

ubuntu qtadb oneplusx screenshot

 

Be careful, you now have the full powers !

Signature Technoblog

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 This 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