How to configure ADB access for Android devices?
Solution 1
Please read the following first: How do I set up Android ADB?
Configuring USB access
First, you don't need root permissions to run ADB if you have set the permissions accordingly. The AOSP site provides examples for Configuring USB Access for Pixel/Nexus devices. You can use the following scheme for non-Nexus devices:
SUBSYSTEM=="usb", ATTR{idVendor}=="xxxx", ATTR{idProduct}=="xxxx", MODE="0600", OWNER="<username>"
Vendor and product ID can be obtained by using lsusb
and searching for your device. (Note: The device actually is a Galaxy Nexus.)
$ lsusb | grep -i samsung
Bus 002 Device 103: ID 04e8:6860 Samsung Electronics Co., Ltd GT-I9100 Phone [Galaxy S II]
So my /etc/udev/rules.d/51-android.rules
udev rule looks like this:
# adb protocol on maguro/toro (Galaxy Nexus)
SUBSYSTEM=="usb", ATTR{idVendor}=="04e8", ATTR{idProduct}=="6860", MODE="0600", OWNER="username"
You may want to repeat this for the other phone states like fastboot if needed. To let the changes take effect either reload udev (sudo udevadm control --reload
) or reboot (recommended).
Making programs available
Instead of modifying the path variable I would suggest adding a symbolic link to the executable either in ~/bin/
(user only) or in /usr/local/bin/
(system wide).
mkdir ~/bin/
ln -s /opt/android-sdk-linux/platform-tools/adb ~/bin/
Solution 2
I bumped into the same issue with a tablet from China (some weird manufacturer).
In addition to /etc/udev/rules.d/51-android.rules
file, I needed to change ~/.android/adb_usb.ini
as well.
Run below on terminal;
sudo gedit ~/.android/adb_usb.ini
and your adb_usb.ini
file should look like:
# ANDROID 3RD PARTY USB VENDOR ID LIST -- DO NOT EDIT.
# USE 'android update adb' TO GENERATE.
# 1 USB VENDOR ID PER LINE.
# ie 0x2207
0x<!!!Your Vendor ID here!!!>
Disconnected and reconnected device and also needed to run below commands on terminal;
adb kill-server
and afterwards
adb start-server
And the device was detected.
Solution 3
Follow these steps:
-
Set android vars
Initially go to your home and press Ctrl + H it will show you hidden files now look for
.bashrc
file, open it with any text editor then place the lines below at the end of file:export ANDROID_HOME=/myPathSdk/android-sdk-linux export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
Reboot
-
Using device to debug
Listen for connection:
adb -a
Connect your Android device and authorise it:
cordova run android --device
Related videos on Youtube
Martin Fejes
Updated on September 18, 2022Comments
-
Martin Fejes over 1 year
I'm using Ubuntu 12.10 and I have installed Android SDK, set it's path in my user
.bashrc
and it works.The problem is that my phone requires adb to be ran by root for permissions, but running adb with sudo I get the following error:
sudo: adb: command not found
I tried to simply use
sudo -E adb start-server
, but it doesn't work. Tried to add the export path line to/root/.bashrc
and (after realizing it didn't help) to/etc/bash.bashrc
.I remember I could set it on my Arch Linux, but I guess my problem now is connected to Ubuntu root account not behaving like I expect it.
What I don't understand is the following:
These don't work:
martin@alyx:~$ sudo adb devices sudo: adb: command not found
This does (typing the full path):
martin@alyx:~$ sudo /opt/android-sdk-linux/platform-tools/adb devices * daemon not running. starting it now on port 5037 * * daemon started successfully * List of devices attached CM7-Blade device
This doesn't work (using -E with sudo):
martin@alyx:~$ sudo -E adb devices sudo: adb: command not found
This works (as root):
martin@alyx:~$ sudo su root@alyx:/home/martin# adb devices List of devices attached CM7-Blade device
I'm totally confused now and I'd appreciate some clarifying on how to set a path for sudo or how else I could solve my problem.
(And please, don't say adb shouldn't be ran as root.)
Thanks in advance!
Edit: By requiring root permissions I mean that I need them because otherwise I get:
$ adb devices List of devices attached ???????????? no permissions
which doesn't occur as superuser. Sorry if it was misunderstanding.
-
Martin Fejes over 11 yearsI tried adding the udev rules for my phone, but it didn't help so I thought maybe I wasn't clear about my problem. Please, if you have the time, see the end of my question.
-
Csabi Vidó over 11 yearsHave you added the correct IDs? modaco.com/topic/329317-guide-ubuntu-and-the-blade Have rebooted your machine afterwards?
adb devices
works for me without root privileges. -
Martin Fejes over 11 yearsYay, it works! I added the udev rules to /etc/udev/rules.d/51-android-rules and apparently it was a mistake. After using /lib/udev/rules.d/11-android.rules, everything was fine! I don't need root persmissions! Thanks a lot!
-
landroni over 9 yearsI'm not sure that this addresses the original question...
-
Panthro about 9 yearsHad the same ???????????? no permissions situation and your answer solved it, thanks.
-
Aquarius Power almost 9 yearsfor some reason it did not work here, I had to start adb server with sudo; any idea where could I look to see why it did not work?
-
Aquarius Power almost 9 yearsI tried with your tip too but nothing changed, any idea where I could look to see why it did not work here?
-
Waffle's Crazy Peanut almost 9 yearsNice one. That worked for me. Along with that, I had to update my adb.
-
Luís de Sousa about 8 years
sudo
or nosudo
this solution is not functional on Ubuntu 14.04. The list of devices is always empty. -
Luís de Sousa about 8 yearsThis solution does not work on Ubuntu 14.04. The list of devices still comes out empty.
-
Dmitry Popov almost 8 yearsThanks a lot, Uygar, finally I've found the solution that works for me.
-
pegu over 7 years
-
Dan Dascalescu over 6 yearsI haven't needed ANY of this in the past year+ of using Ubuntu 16. This answer might be outdated.
adb
just worked on Samsung S7, Nexus 5X, Pixel and Pixel 2. -
Csabi Vidó over 6 years@DanDascalescu It's supposed to work out of the box, only when it doesn't one is looking for answers and the advice about the udev rule is still correct if it doestn't exists for a specific device as far as I am aware.