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
- Download the latest Android SDK from the Google’s developers pageย โ Click Here
- 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.
- 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.
- First, navigate to the the home directory of your profile. Execute the following command in the command terminalย (Modify it with your username):
- 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.
- Finally run the following command to launch the Android SDK manager:
./android
- This will open a GUI based Android SDK manager. Download the necessary packages from the tool.
- 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.
- 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
- 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
- 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:
- 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:
Manufacturer USB Vendor ID Acer 0502 Dell 413c Foxconn 0489 Garmin-Asus 091E HTC (Older Phones) 0bb4 HTC (Newer phones) 18d1 Huawei 12d1 Kyocera 0482 LG 1004 Motorola 22b8 Nexus One/S 18d1 Nvidia 0955 Pantech 10A9 Samsung 04e8 Sharp 04dd Sony Ericsson 0fce ZTE 19D2 - 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
- 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.
I tried all the above and “adb devices” still showed nothing. I’m also on 16.04.
Hey! I think using android sdk from bin is no longer allowed. ๐
Anybody help me out in downloading drivers on ubuntu 16.04
I don’t have 70-android.rules available under path.
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. ๐
Thanks, worked for me. ๐
Same here, Trusty Tar, what should that use?
What should the android rules number be for Peppermint 6 running Ubuntu 14.04?
Do you have an update for Trusty Tahr?
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.
๐
easily??ยฟ???ยฟยฟ?ยฟ??ยฟยฟยฟ? where is the easily part???????
I am also waiting for him to show how easy it is kkkkkkk
not working for me … I even added ~/.android/adb_usb.ini 0x1004 – stands for LG, stuck with this ๐