41

I'm trying to use adb from a Ubuntu(+Cinnamon) machine. The problem is that I get following message from adb devices:

List of devices attached
TA8830OIVO  no permissions

Where TA8830OIVO is my Motorola G device.

I changed android rules in /etc/udev/rules.d/51-android.rules

SUBSYSTEM=="usb", ATTR{idVendor}=="22b8", ATTR{idProduct}=="2e76",
MODE="0666", GROUP="plugdev", SYMLINK+="android_adb", OWNER="axel"

I also restarted udev service and adb being installed on my personal laptop I'm the only user with all the priveledges needed (plugdev group and so on).

Is there a way to run adb without invoking sudo?

shadox
  • 523
  • 1
  • 4
  • 6
  • 1
    Restarting udev and `sudo udevadm trigger` didn't work for me. I had to restart the computer and then it worked just fine – Rafael Xavier Feb 19 '18 at 19:22
  • refer: https://android.stackexchange.com/questions/177318/why-cant-i-run-adb-via-udev/214369#214369 – diyism Jul 08 '19 at 12:11

7 Answers7

83

Change the USB mode in your phone to File Transfer. That's what worked for me.

NuttLoose
  • 991
  • 7
  • 6
31
  1. Remember to run sudo udevadm trigger to get the changes applied (or reboot, but where's the fun in that).
  2. Instead of writing your own rules use https://github.com/M0Rf30/android-udev-rules
  3. Make sure you have the latest ADB version (1.0.35 102d0d1e73de-android). Earlier ones didn't work with USB-C for me.
zamber
  • 411
  • 4
  • 5
  • Thanks but it's kinda old question. I switched to Mac 2 years ago. I find it stupid to do stuff like **lsusb** and then modify rules when it should be done automatically... I gave up after so many years of ubuntu use. Can't find a decent Linux Desktop system. – shadox Apr 08 '16 at 21:06
  • 1
    The question is 6 months old and still valid for posterity. 1y ago I dumped OS X after a 3y affair and went back to Linux for similar reasons ;). Linux has parts where it gets frustrating but there's a similar amount of tinkering required in OS X if you use homebrew+zsh+iTerm2. The difference is that stuff if mostly closed-source or outdated versions of FOSS but with a nice GUI and UX (for the most part). Using the rules from the repo makes it mostly a one-time setup step. Considering the arcana of getting the Android SDK to work in a sane way it's toddlers-play. – zamber Apr 10 '16 at 00:08
  • 1
    Running this and `service udev restart` didn't work for me. I had to restart the computer and then it worked just fine. – Rafael Xavier Feb 19 '18 at 19:21
  • On ubuntu 16.04 setting the udev rules, changing the usb mode on phone to file transfer worked like a charm. No restart needed. – Gautam Jun 22 '18 at 14:13
  • On ubuntu 16.04 with a Pixel 2 adding the rules from the gitbub of point 2 works without even going in to file transfer mode. – Mike Hanafey Oct 24 '18 at 15:21
  • second step was the one, that solved my problem – illgoforit Jul 20 '19 at 10:29
6

If you restart the ADB server with sudo, it will work.

sudo adb kill-server
sudo adb start-server
1

For Amazon Fire OS 8, an Android based OS, you can go to "Settings > Device Options > Developer Options". You may need to enable it.

Ensure "USB Debugging" is on (in your case, it is).

Then go to "Networking > Select USB Configuration". Choose "MTP (Media Transfer Protocol)". This allows the computer to send files back and forth.

1

remove adb package installed via apt

$sudo apt remove adb

download latest adb from
https://developer.android.com/studio/releases/platform-tools

set the path to platform tools(better put these two lines in ~/.bashrc file)

export PATH= /<path-to-android-sdk-folder>/android-sdk/tools/bin<br>
export PATH= /<path-to-android-sdk-folder>/android-sdk/platform-tools

run

$source ~/.bashrc

check adb path

$which adb

start adb in sudo(I needed to give absolute path to adb when running in sudo )

$sudo /<path-to-android-sdk-folder>/android-sdk/platform-tools/adb kill-server
$sudo /<path-to-android-sdk-folder>/android-sdk/platform-tools/adb start-server
$adb shell

DONE.
it works irrespective of what USB mode( MIDI, transferring files, charging) of android phone. It works in all.

0

Define custom gradle function:

task _adb_restart {
def adb = android.getAdbExe().toString()
group '__custom'
  doLast {
    exec {
      commandLine 'bash', '-c', '/bin/echo **root_password** | sudo -S ' + adb + ' kill-server'
    }
    exec {
      commandLine 'bash', '-c', '/bin/echo **root_password** | sudo -S ' + adb + ' devices'
    }
  }
}
Pablo Bianchi
  • 14,308
  • 4
  • 74
  • 117
0

Best solution and what worked better for me is to install adb from Ubuntu package. This gives you a community-maintained default set of udev rules for all Android devices.

example:

$ sudo apt-get install adb
Simon Sudler
  • 3,771
  • 3
  • 20
  • 33