How to Setup ADB and USB drivers on Ubuntu

13

Android operating system is the most versatile and powerful mobile OS platform so far and the reason behind is simple – a huge developer network. Being an open source platform, development on Android is a breeze and one can explore even the hardware level functions of the device. Development flexibility on this scale is missing in iOS and Windows niche because of their proprietary nature which restricts developers from exploring and tweaking. Many developers across the world strive for the improvement of the OS as well as the development for individual devices which brings many mods and ROMs to the Android users.

Being a Linux based platform, many Android developers use Linux based PC’s for the development which as you can realize, is the worst nightmare for beginners. Most beginners struggle to get their device detected by the PC which is the first step in the process of development. Without a proper connection with the device, one cannot carry on live debugging and tests on smartphones. So, you need to install proper USB drivers and setup Android SDK to obtain ADB tools and development kit which is used for the Android development.

Android SDK is a development environment for the Android operating system which allows you to simulate apps and mods on the emulator and test them on live devices with careful debugging. Developers need to take proper logs during the test phase to understand and resolve the errors during the process. For this, you will need a working ADB and USB drivers on your PC. ADB is the acronym for the Android  Debug Bridge which is a versatile command line tool that acts as a bridge between the Android device and the PC allowing data to be transfer.

In this tutorial, we will show you how to setup Android SDK on Ubuntu and setup ADB/USB drivers compatible with your Android device. The process involves playing with a few Linux commands but you don’t need to have a prior knowledge of these as we laid them quite simply. However, we request you to understand the process for knowledge purpose which will improve your understanding towards Android development. Follow the tutorial carefully and avoid typos unless you want to face a lot of errors in the process. So, let’s jump into the tutorial without any further ado

Prepare your Device

  • Make sure to use a proper USB cable while connecting to your PC as faulty cables might not show your device on the PC.
  • Enable USB Debugging on your phone from Settings> Developer options. If you do not find Developer option under device settings, read the instructions given here.

How to Setup ADB/USB drivers on Ubuntu

Part 1: Installing SDK and ADB

  1. Download the latest Android SDK from the Google’s developers page → Click Here
  2. At the time of writing this tutorial, the SDK version is r24.0.2. So, we will use the SDK file name as android-sdk_r24.0.2-linux.tgz in this tutorial for convenience, you must change the name to the version you have downloaded.
  3. Extract the downloaded tgz package to your profile directory which will be /home/your-username. To do this, follow the below instructions:
    • First, navigate to the the home directory of your profile. Execute the following command in the command terminal (Modify it with your username):
      cd /home/your-username
    • Now run the following command to extract the tgz package (Replace file name with the version you have downloaded):
      tar -xvzf android-sdk_r24.0.2-linux.tgz

      Don’t close the command terminal yet.

  4. Navigate to the tools folder of the SDK package you have extracted. To do this run the following command.
    cd ~/android-sdk-linux/tools

    Here, ~ indicates the current directory which should be /home/your-username/ directory if you have continued in the same terminal as in step 3.

  5. Finally run the following command to launch the Android SDK manager:
    ./android
  6. This will open a GUI based Android SDK manager. Download the necessary packages from the tool.
  7. To run ADB commands, you need to edit the bashrc file to add the ADB path in the environment variables of your PC. To edit the bashrc file, use the following command (You can use any editor)
    sudo gedit .bashrc

    Using sudo command may ask for the Linux password, enter your user password. This will allow you to operate the command with superuser permissions for a short time as specified in the sudoers file.

  8. The previous command will open the bashrc file in the GNU editor, add the following lines at the end of the file and save it.
    export PATH=${PATH}:~/android-sdk-linux/tools
    export PATH=${PATH}:~/android-sdk-linux/platform-tools

This completes the SDK and ADB installation on your Ubuntu based PC. Now follow the below instructions to install USB drivers for your Android smartphone on your PC. Part 2: Installing USB drivers for your device

  1. Create an empty file in the /etc/udev/rules.d/ directory with the following name:
    • If you’re using the Ubuntu version Gusty/Hardy/Dapper, create the file with the name 50-android.rules. Execute the following command to do so:
      sudo gedit /etc/udev/rules.d/50-android.rules
    • If you’re using the Ubuntu version Karmic Koala/Lucid Lynx/Maverick Meerkat, create the file with the name 70-android.rules. Execute the following command to do so:
      sudo gedit /etc/udev/rules.d/70-android.rules
  2. Type the following content in the editor and save it.
    • For Gusty/Hardy: SUBSYSTEM==”usb”, SYSFS{idVendor}==”USB-VENDOR-ID”, MODE=”0666″
    • For Dapper: SUBSYSTEM==”usb_device”, SYSFS{idVendor}==”USB-VENDOR-ID”, MODE=”0666″
    • For Karmic Koala: SUBSYSTEM==”usb”, SYSFS{idVendor}==”USB-VENDOR-ID”, MODE=”0666″
    • For Lucid Lynx: SUBSYSTEM==”usb”, SYSFS{idVendor}==”USB-VENDOR-ID”, MODE=”0666″
    • For Maverick Meerkat: SUBSYSTEM==”usb”, ATTR{idVendor}==”USB-VENDOR-ID”, MODE=”0666″

    Change the USB-VENDOR-ID string with the USB vendor ID of your device. You can get it from the table below:

    ManufacturerUSB Vendor ID
    Acer0502
    Dell413c
    Foxconn0489
    Garmin-Asus091E
    HTC (Older Phones)0bb4
    HTC (Newer phones)18d1
    Huawei12d1
    Kyocera0482
    LG1004
    Motorola22b8
    Nexus One/S18d1
    Nvidia0955
    Pantech10A9
    Samsung04e8
    Sharp04dd
    Sony Ericsson0fce
    ZTE19D2
  3. Now you have to append read permissions to the created file for all the profiles in the PC. Use one of the following command to do this:
    sudo chmod a+rx /etc/udev/rules.d/50-android.rules

    or

    sudo chmod a+rx /etc/udev/rules.d/70-android.rules
  4. Reboot your PC for the changes to take place.

That’s it. You have successfully installed ADB and USB drivers on your Ubuntu PC. Now connect your device to the PC using an USB cable and  execute the following command in the terminal to test whether the device is detected by your PC or not.

adb devices

If your device is detected by the PC, you will see a serial number similar to the one below in the terminal.

List of devices attached V00776140945011 device

Feel free to ask any queries in the comments section below.

  • pallav

    Hey! I think using android sdk from bin is no longer allowed. 😀

  • aodh

    I tried all the above and “adb devices” still showed nothing. I’m also on 16.04.

  • Sana Qureshi

    Thanks, worked for me. 🙂

  • Vybhav Jannat

    Anybody help me out in downloading drivers on ubuntu 16.04

  • sushil

    I don’t have 70-android.rules available under path.

  • Philip KP

    Just so you know, it is easier to just type “sudo apt-get install android-tools-adb” into terminal and press enter. It does it all for you. 🙂

  • jefersonxsilva

    I am also waiting for him to show how easy it is kkkkkkk

  • Yves G.

    Same here, Trusty Tar, what should that use?

  • Alynur

    What should the android rules number be for Peppermint 6 running Ubuntu 14.04?

  • Ed Grange

    Do you have an update for Trusty Tahr?

  • Joao Domingues

    The first part was ok , I think….

    But the drivers parts, uuffff…
    This is guru level instructions… I cannot identify the version of Ubuntu you are talking about

    lsb_release -a output is
    Release: 14.04
    Codename Trusty

    what instructions should I follow for the drivers ?

    Thanks in advance.

    🙂

  • BitporBit

    easily??¿???¿¿?¿??¿¿¿? where is the easily part???????

  • not working for me … I even added ~/.android/adb_usb.ini 0x1004 – stands for LG, stuck with this 🙁