Tutorial How to Setting up ADB on Linux/Ubuntu

Monday, July 23, 20120 comments

This guide is for the Linux user that has never setup the Android sdk or adb. Prior to beginning this process you should know what terminal is, be comfortable operating within it, and be able to follow simple, but detailed, instructions.


Tips, Tricks, Things to Have and Good to Knows:



Now is not the time to be in a hurry, take your time and be careful. Even if you're fast this takes a fair bit of time with everything that needs to download. Be prepared to devote a solid hour of your time and not need ADB for another 2+ hours depending on the speed of your Internet connection



1) An android phone.

2) A working USB data cable to connect you phone to your computer

3) A computer running a Linux distribution (This guide was written based off of Ubuntu 10.10)


Many of the “code” steps can be copied and pasted into the terminal to make life easier and reduce the risk of error. You might be familiar with the keyboard shortcuts for Copy (Ctrl+c) and Paste (Ctrl+v) but then might be confused as to why they don't work in terminal. You can either use “right-click” on your mouse and select “paste” but for speed and ease the keyboard shortcuts for cut/copy/past in terminal are the same EXCEPT for adding “Shift” while inside terminal. So Paste is Shift+Ctrl+v.

If you don't know or understand what copy/paste is then that should be you cue that modifying your Android device is probably not right for you. Stop now before you end up destroying your expensive phone.

Lets Begin:

Step 1) Create a folder named "ANDROID" in your home folder

Note: Remember Linux is case sensitive, so if you don't don't use all capitals on this folder name don't use all capitals for it later in your folder paths. If you accurately follow these directions that won't be an issue.

Step 2) Download the Android SDK for Linux(i383) from here: (http://developer.and.../sdk/index.html) and place it in the newly created ANDROID folder



Step 3) Right click on "android-sdk_r10-linux_x86.tgz" and select “Extract here”



Note: "android-sdk_r10-linux_x86.tgz" is the file you just downloaded and moved to the ANDROID folder.



Step 4) Open the Ubuntu Software Center, from the menu select Edit--->Software Sources--->Input your password--->Other Software tab. Check "Canonical Partners" then “Close”.



Note: There are several options in this menu DO NOT check “Canonical Partners (Source Code)”



Step 5) In the Ubuntu Software Center look to the left column under "Get Software" and ensure that it is expanded. Select "Canonical Partners" and in the right window find the "Sun Java™ Development Kit(JDK) 6", click "more info." In the "Add-Ons" section check the (sun-java6-javadb) package and (sun-java6-source) options. Click "Apply Changes," and accept the License Agreement.



Exit the Software Center after install.



Note: There are several “Sun Java etc. etc.” selections available in the right window; locate "Sun Java™ Development Kit(JDK) 6" also named as “sun-java6-jdk”. Do not install any of the other packages.



Step 6) Start a terminal session and input:


sudo vi /etc/udev/rules.d/70-android.rules


Terminal will ask for your password, once that's provided it will then output this:

~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
"/etc/udev/rules.d/70-android.rules" [New File]


Once it does close the terminal window.

Step 7) Start a new terminal window and input:

gksudo gedit /etc/udev/rules.d/70-android.rules

This will open the (blank) file you created in step 6 with geditor.

Note: What you type/paste into this file will depend on your particular device. This file tells ADB/Fastboot/the Android SDK what kind of Android device it's trying to talk to.

A quick Google search of "(your phone here) adb vendor id" should yield exactly what you need to paste into this file. It is also important to note that some phones (like the Samsung Galaxy Nexus) have different id's for ADB and fastboot; you will want to add both of these if that's the case.

It should look roughly like this (example is from CDMA Galaxy Nexus):

SUBSYSTEM=="usb", ATTRS{idVendor}=="04e8", MODE="0666", GROUP="adbusers" #regular/debug
SUBSYSTEM=="usb", ATTRS{idVendor}=="18d1", MODE="0666", GROUP="adbusers" #fastboot

Paste/type the vendor id's exactly as you find them into the blank file, save and exit geditor, exit terminal.

Step 8) Open your "ANDROID" folder. Open the folder that you extracted from “android-sdk_r10-linux_x86.tgz” multi-select the contents of the entire folder (folders add-ons, platforms, tools and a readme.txt) and Cut/Paste them directly into the “ANDROID” folder (one level up, where “android-sdk_r10-linux_x86.tgz” is).

Delete the now empty shell folder.

Navigate to “ANDROID/Tools/” laocate the file named "android" and double click it. A pop-up box appears stating:

“Do you want to run “android” or display its contents?”

Select "Run" which opens the Android SDK and AVD Manager. In the left navigation panel select “available packages” select "Install Selected"--->"Install"

After downloading a pop-up will appear about ADW, select "Yes." Check the dialogue box for a successful kill/restart of ADW after it downloads and installs everything; once it does select "Close" and exit the SDK Manager.

Step 9) Open a terminal session and type:

cd /home/*****/ANDROID/platform-tools

NOTE: REPLACE “*****” WITH YOUR USERNAME! For example, on my laptop it would look like this “cd /home/loganmobile/ANDROID/platform-tools”

Pro-tip: navigate to the adb file in the platform-tools folder, right click-->”Properties” then copy/paste the path after the cd command in your terminal window.

Step 10) On your Android (Android 1.x-2.x) phone go to:

Settings--->Applications--->Development--->USB Debugging. Ensure it is checked. Connect your phone via your usb cable to the computer but do not mount as sdcard/external storage.

Step 11) Back in your terminal window type: (If you've closed terminal don't forget your cd command (change directory) to the platform-tools folder in the new terminal window.)


./adb devices




It should output:
List of devices attached
0149**********19                   device



Note: ********* in the example above will be numbers and letters that uniquely identify you phone.

Note2: You may also see this message:
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
List of devices attached
0149**********19                   device


This is normal and only indicates that the ADB server had not started.

If your device doesn't appear then go back to step 7 and ensure that you have the proper id's for your phone in the “70-android.rules” file.

In the terminal window type:

adb reboot bootloader

Observe your phone to see it boots into the bootloader. Many/most newer phones also utilize fastboot so type:

fastboot devices

It should output:
0149**********19        fastboot

Note: ********* in the example above will be numbers and letters that uniquely identify you phone.
If your device doesn't appear then go back to step 7 and ensure that you have the proper id's for your phone in the “70-android.rules” file or verify that your phone does not use fastboot. If your phone does not utilize fastboot reboot the phone manually and skip to step12.
In the terminal window type:

fastboot reboot

Observe your phone to see it boots normally.

Step 12) A few more things to finish the job.

Open a new terminal instance and type:

gedit ~/.bashrc

Add this line to the bottom of the file that opens:

export PATH=$PATH:/home/*****/ANDROID/platform-tools

Note: Once again ***** is your Ubuntu username.
Save the file and exit gedit. Close the terminal window.

Reboot your computer and verify that ADB still works by repeating step 11.

Note: Once again, don't forget the cd command (change directory).




Credit to qwirked (OP) from Rootzwiki forum
Share this article :
Powered by Blogger.
 
Copyright © 2011. Android Tutorials - All Rights Reserved
Proudly powered by Blogger