5,604,764 Members 31,791 Now Online
XDA Developers Android and Mobile Development Forum

Enable ADB under Ubuntu/Linux

Tip us?
 
Sblood86
Old
(Last edited by Sblood86; 6th June 2012 at 06:52 PM.)
#1  
Sblood86's Avatar
Recognized Developer - OP
Thanks Meter 356
Posts: 354
Join Date: Apr 2011
Location: Middle of nowhere, Texas

 
DONATE TO ME
Default Enable ADB under Ubuntu/Linux

Alright so it turns out making ADB work for the Kindle Fire under Ubuntu is just a touch more difficult than in Windows.

Thanks to Gbhil (@ AndroidCentral) for the write up on windows it was a great jumping off point to try to figure this out.
Also thanks to the guys on chat.andirc.net (Skourg3 in particular for helping me figure this out the first time).

Let's get down to the nitty gritty yeah?

First you will still need the entry provided by Gbhil, go ahead and set it using the echo command in a terminal.
Code:
echo 0x1949 >> ~/.android/adb_usb.ini
You can confirm that it took by using the cat command
Code:
cat ~/.android/adb_usb.ini
You should get a return of '0x1949' (plus any other rules that you may have added in the past).

Now really that should work but everytime you run adb you will have to either run it as root or using the sudo command. To allow standard user access we have to setup a udev rule.
Code:
sudo gedit /etc/udev/rules.d/51-android.rules
That should open up gedit for you to edit the file 51-android.rules. If this is the first time you have added any udev rules the file will be empty as gedit will have just created it for you. go ahead and add in the following.
Code:
# adb/fastboot protocols for blaze / otter (Amazon Kindle Fire)
SUBSYSTEM=="usb", ATTR{idVendor}=="1949", ATTRS{idProduct}=="0006", MODE="0660", OWNER="root", GROUP="androiddev", SYMLINK+="android%n"
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTRS{idProduct}=="0100", MODE="0660", OWNER="root", GROUP="androiddev", SYMLINK+="android%n"
Save that than add in the user group androiddev.
Code:
sudo addgroup --system androiddev
And add your username to that group.
Code:
sudo adduser <username> androiddev
Replace <username> with your primary username without the <> around it.

After that you will need to logout and log back in for these values to apply. You will probably need to restart the adb server as well.

Change directory to your platform-tools directory and run the following.
Code:
./adb kill-server
./adb start-server
Assuming all went well that should work properly and you can than connect through adb, if for some reason this doesn't work try restarting your computer (though I do not believe this is necessary).

If you don't want to type the "./" before all of your adb and fastboot commands, you need to add their parent directory into your PATH environment variable. For example, (assuming you are using the bash shell) if you have adb and fastboot in your /home/<username>/bin directory, you want to define...

Code:
PATH=~/bin:${PATH}
or
Code:
PATH=${PATH}:~/bin
It just depends on whether you want your own binaries to be used before the system equivalents or after. Most people would probably use the first one to have your own binaries be the preferred ones, but either one should work for adb and fastboot since there are no system binaries by the same names.

If you don't want to have to do this for every shell you open, you can place the definition at the end of your ~/.bashrc file. If you need it for you your login shell, you also need to put it into your ~/.bash_profile file. If you don't want to maintain two parallel files with much of the same information, take a look at this post.
The Following 7 Users Say Thank You to Sblood86 For This Useful Post: [ Click to Expand ]
 
kinfauns
Old
#2  
kinfauns's Avatar
Developer Committee / Senior Moderator
Thanks Meter 2893
Posts: 1,646
Join Date: Jan 2012
Quote:
Originally Posted by Sblood86 View Post
First you will still need the entry provided by Gbhil, go ahead and set it using the echo command in a terminal.
Code:
echo ~/.android/adb_usb.ini 0x1949
Thanks for the guide on setting this up for linux. I just wanted to point out a small error in the instructions. The echo command above is incorrect and will not do what you intended. It should be corrected to

Code:
echo 0x1949 >> ~/.android/adb_usb.ini
That will create or append to the file as necessary.
The Following 3 Users Say Thank You to kinfauns For This Useful Post: [ Click to Expand ]
 
freefaling
Old
#3  
Member
Thanks Meter 20
Posts: 96
Join Date: Dec 2010
Location: Lahore
Default no adb_usb.ini file

Quote:
Originally Posted by kinfauns View Post
Thanks for the guide on setting this up for linux. I just wanted to point out a small error in the instructions. The echo command above is incorrect and will not do what you intended. It should be corrected to

Code:
echo 0x1949 >> ~/.android/adb_usb.ini
That will create or append to the file as necessary.
Somehow the guide I followed for setting up adb/fastboot on Ubuntu did not create the udb_usb.ini file.

I had to go into android-sdk-linux folder on my home directory and copy the one provided with KFU. Only then I could use the echo command.
 
kinfauns
Old
(Last edited by kinfauns; 6th May 2012 at 07:08 PM.)
#4  
kinfauns's Avatar
Developer Committee / Senior Moderator
Thanks Meter 2893
Posts: 1,646
Join Date: Jan 2012
Quote:
Originally Posted by freefaling View Post
Somehow the guide I followed for setting up adb/fastboot on Ubuntu did not create the udb_usb.ini file.

I had to go into android-sdk-linux folder on my home directory and copy the one provided with KFU. Only then I could use the echo command.
This...

Code:
echo 0x1949 >> ~/.android/adb_usb.ini
will definitely create the file if it doesn't exist, but only if the ~/.android/ directory exists (with the correct permissions). It won't make those directories if they don't exist. I'm guessing the .android directory wasn't there when you ran the command.
 
freefaling
Old
#5  
Member
Thanks Meter 20
Posts: 96
Join Date: Dec 2010
Location: Lahore
Quote:
Originally Posted by kinfauns View Post
This...

Code:
echo 0x1949 >> ~/.android/adb_usb.ini
will definitely create the file if it doesn't exist, but only if the ~/.android/ directory exists (with the correct permissions). It won't make those directories if they don't exist. I'm guessing the .android directory wasn't there when you ran the command.
I read a lot of guides and did what they all said and ended up with a working adb command but my kindle was still not detected. At the end it was this thing that solved the issue.

I dont think I had that "android" folder (i did not unhide the home folder to check but since i setup the android sdk inside "android-sdk-linux" folder, i doubt "android" folder was there).

It's because of these tiny details I was sugesting that you, sir, create a how-to for setting up adb on ubuntu (only if you feel comfortable doing it, that is).

Thanks.

Sent from my Amazon Kindle Fire using XDA
 
Lotek
Old
#6  
Member
Thanks Meter 30
Posts: 66
Join Date: Dec 2008
Location: Boston
My OS is Mint 12, so same as Ubuntu (except for Unity and a bit of non open-source software) and setting up ADB was also a little bit more difficult than I anticipated. I don't know how other distros are.

The guide that got me most of the way there was this one http://forum.xda-developers.com/show...4&postcount=62, and then I hit the same problems as the OP. I had to do a bit of mostly useless searching and reading before I found the entry provided by Gbhil and .adb/ devices made the legend "0123456789ABCDEF device" pop up.

I updated every platform in the sdk while I was at it, oops, must get that 4 or 5 gigs of space in my Home folder back sometime.

A kindle fire specific guide for Ubuntu would be awesome, I hereby second freefaling's nomination of you, Sblood86, as author of said guide, if you're into it, because you seem pretty good at it.
 
kinfauns
Old
#7  
kinfauns's Avatar
Developer Committee / Senior Moderator
Thanks Meter 2893
Posts: 1,646
Join Date: Jan 2012
Someone asked me about my Ubuntu setup last night and I thought that I should contribute back to this thread with the same information.

You can add another udev rule to cover fastboot commands on FFF so they don't have to be run as root...

Code:
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTRS{idProduct}=="0100", MODE="0660", OWNER="root", GROUP="androiddev", SYMLINK+="android%n"
If you don't want to type the "./" before all of your adb and fastboot commands, you need to add their parent directory into your PATH environment variable. For example, (assuming you are using the bash shell) if you have adb and fastboot in your /home/<username>/bin directory, you want to define...

Code:
PATH=~/bin:${PATH}
or

Code:
PATH=${PATH}:~/bin
It just depends on whether you want your own binaries to be used before the system equivalents or after. Most people would probably use the first one to have your own binaries be the preferred ones, but either one should work for adb and fastboot since there are no system binaries by the same names.

If you don't want to have to do this for every shell you open, you can place the definition at the end of your ~/.bashrc file. If you need it for you your login shell, you also need to put it into your ~/.bash_profile file. If you don't want to maintain two parallel files with much of the same information, take a look at this link.

http://www.joshstaiger.org/archives/...rofile_vs.html

I follow the recommendation at the end.

Hope that helps someone.
The Following User Says Thank You to kinfauns For This Useful Post: [ Click to Expand ]
 
Sblood86
Old
(Last edited by Sblood86; 30th May 2012 at 06:45 PM.)
#8  
Sblood86's Avatar
Recognized Developer - OP
Thanks Meter 356
Posts: 354
Join Date: Apr 2011
Location: Middle of nowhere, Texas

 
DONATE TO ME
Quote:
Originally Posted by kinfauns View Post
Someone asked me about my Ubuntu setup last night and I thought that I should contribute back to this thread with the same information.

You can add another udev rule to cover fastboot commands on FFF so they don't have to be run as root...

Code:
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTRS{idProduct}=="0100", MODE="0660", OWNER="root", GROUP="androiddev", SYMLINK+="android%n"
If you don't want to type the "./" before all of your adb and fastboot commands, you need to add their parent directory into your PATH environment variable. For example, (assuming you are using the bash shell) if you have adb and fastboot in your /home/<username>/bin directory, you want to define...

Code:
PATH=~/bin:${PATH}
or

Code:
PATH=${PATH}:~/bin
It just depends on whether you want your own binaries to be used before the system equivalents or after. Most people would probably use the first one to have your own binaries be the preferred ones, but either one should work for adb and fastboot since there are no system binaries by the same names.

If you don't want to have to do this for every shell you open, you can place the definition at the end of your ~/.bashrc file. If you need it for you your login shell, you also need to put it into your ~/.bash_profile file. If you don't want to maintain two parallel files with much of the same information, take a look at this link.

http://www.joshstaiger.org/archives/...rofile_vs.html

I follow the recommendation at the end.

Hope that helps someone.
I spent something like 3 weeks trying to find the rule that worked with fastboot lol... thanks!

Your link is dead btw.
 
kinfauns
Old
#9  
kinfauns's Avatar
Developer Committee / Senior Moderator
Thanks Meter 2893
Posts: 1,646
Join Date: Jan 2012
Quote:
Originally Posted by Sblood86 View Post
I spent something like 3 weeks trying to find the rule that worked with fastboot lol... thanks!

Your link is dead btw.
Well it worked a couple of days ago when I made my post. It's not my fault it took you so long to read it.

All it really said was to add...

Code:
if [ -f ~/.bashrc ]; then
   source ~/.bashrc
fi
to the .bash_profile file so that it will source the .bashrc file regardless of the way you got to the shell. Then you only have to maintain the .bashrc file and only put login shell specific info into .bash_profile

I picked up another tidbit yesterday while engrossed in the whole CWMR bricking thread. Ubuntu has a plugdev group that's used for (mounting?) hot-pluggable firewire/USB devices... sounds a lot like the KF. The first user created on the system is automatically put into that group. Since most Ubuntu desktop are going to be single user machines anyway, that's going to be THE user for the majority of these cases. So, creating a androiddev group just for the KF is probably not necessary most of the time. You can just skip the addgroup and adduser to group commands if you just want to adjust your rules to use the plugdev group instead.
The Following User Says Thank You to kinfauns For This Useful Post: [ Click to Expand ]
 
hortstu
Old
#10  
Member
Thanks Meter 1
Posts: 51
Join Date: Sep 2010
First I'm going to apologize for not being good with this stuff. Now I'm going to ask questions that will probably frustrate some readers. If you aren't irritated by them please help me out.

Quote:
Originally Posted by Sblood86 View Post

First you will still need the entry provided by Gbhil, go ahead and set it using the echo command in a terminal.
Code:
echo 0x1949 >> ~/.android/adb_usb.ini
What is the entry provided by gbhil? Where do I get it? I thought I had adb in here but apparently I don't because when I run the echo command I'm getting "no such file or directory."

Can anyone dumb this down for me just a bit. Add the steps I'm obviously going to need as a newb?

Thanks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes