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

7 Answers7

83

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

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
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
  • 17,371
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
  • 4,111