设置开发设备(????????????没有权限)

发布于 2025-01-04 12:21:54 字数 1174 浏览 2 评论 0 原文

我使用的是三星 Galaxy Nexus 手机(Android 4.0 平台)。

我正在 Ubuntu Linux 操作系统上开发 Android 应用程序。我想直接在三星手机设备上运行我的应用程序,因此我执行了以下设置步骤:

  1. 在我的项目 AndroidManifest.xml 文件中,添加 android:debuggable="true " 到我的项目 AndroidManifest.xml 文件中的 元素

  2. 在设备上的设置> 中启用安全性 未知来源

  3. 在设备上的设置>中开发者选项已启用USB调试

  4. 在我的计算机上,使用以下内容创建了/etc/udev/rules.d/51-android.rules文件内容:

    SUBSYSTEM==“usb”,ATTR {idVendor}==“04E8”,MODE =“0666”,GROUP =“plugdev” 
    
  5. 在我的计算机上,运行chmod a+r /etc/udev/rules.d/51-android.rules 命令

然后,在我的计算机上打开一个终端并执行 adb devices 命令,我得到:

List of devices attached 
????????????    no permissions

因为我没有看到我的设备但只有 ????????????没有权限,然后我运行以下命令:

 adb kill-server
 adb start-server
 adb devices

但我仍然得到:

List of devices attached 
????????????    no permissions

为​​什么?我缺少什么?

I am using a Samsung galaxy nexus phone (Android 4.0 platform) .

I am developing Android app on Ubuntu linux OS. I would like to run my application directly on the Samsung handset device, so I performed the following setup steps:

  1. in my project AndroidManifest.xml file, added android:debuggable="true" to the <application> element

  2. On the device, in the Settings > Security enabled Unknown sources

  3. On the device, in the Settings > Developer options enabled USB debugging

  4. On my computer, created the /etc/udev/rules.d/51-android.rules file with the following content:

    SUBSYSTEM=="usb", ATTR{idVendor}=="04E8", MODE="0666", GROUP="plugdev" 
    
  5. On my computer, run the chmod a+r /etc/udev/rules.d/51-android.rules command

Then, on my computer I opened a terminal and executed the adb devices command, I got:

List of devices attached 
????????????    no permissions

Since I did not see my device but only ???????????? no permissions, I then run the following commands:

 adb kill-server
 adb start-server
 adb devices

But I still got:

List of devices attached 
????????????    no permissions

Why? What am I missing?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(30

惜醉颜 2025-01-11 12:21:54

对我有用的是杀死并再次启动 adb 服务器。在 Linux 上:sudo adb Kill-server,然后 sudo adb start-server。然后它将检测几乎所有开箱即用的设备。

What works for me is to kill and start the adb server again. On linux: sudo adb kill-server and then sudo adb start-server. Then it will detect nearly every device out of the box.

梦回旧景 2025-01-11 12:21:54

直到我终于在这里找到答案之前,一切都对我不起作用:
http://ptspts .blogspot.co.il/2011/10/how-to-fix-adb-no-permissions-error-on.html

我将文本复制到此处,以防它在 未来。

创建一个名为 /tmp/android.rules 的文件,其中包含以下内容(十六进制供应商编号取自供应商列表页面):

SUBSYSTEM=="usb", ATTRS{idVendor}=="0bb4", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0e79", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0502", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0b05", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="413c", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0489", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="091e", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="18d1", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0bb4", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="12d1", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="24e3", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="2116", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0482", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="17ef", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="1004", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="22b8", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0409", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="2080", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0955", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="2257", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="10a9", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="1d4d", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0471", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="04da", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="05c6", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="1f53", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="04e8", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="04dd", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0fce", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0930", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="19d2", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="1bbb", MODE="0666"

运行以下命令:

sudo cp /tmp/android.rules /etc/udev/rules.d/51-android.rules
sudo chmod 644   /etc/udev/rules.d/51-android.rules
sudo chown root. /etc/udev/rules.d/51-android.rules
sudo service udev restart
sudo killall adb

断开手机和计算机之间的 USB 电缆。

重新连接手机。

运行 adb devices 以确认现在拥有访问手机的权限。

请注意,可以在 .rules 文件中使用 , USER="$LOGINNAME" 代替 , MODE="0666",替换为$LOGINNAME 为您的登录名,即 id -nu 打印的内容。

在某些情况下,可能需要为 udev 规则文件指定一个接近末尾的名称,例如 z51-android.rules

Nothing worked for me until I finally found the answer here:
http://ptspts.blogspot.co.il/2011/10/how-to-fix-adb-no-permissions-error-on.html

I'm copying the text here in case it disappears in the future.

Create a file named /tmp/android.rules with the following contents (hex vendor numbers were taken from the vendor list page):

SUBSYSTEM=="usb", ATTRS{idVendor}=="0bb4", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0e79", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0502", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0b05", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="413c", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0489", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="091e", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="18d1", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0bb4", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="12d1", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="24e3", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="2116", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0482", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="17ef", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="1004", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="22b8", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0409", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="2080", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0955", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="2257", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="10a9", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="1d4d", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0471", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="04da", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="05c6", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="1f53", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="04e8", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="04dd", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0fce", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0930", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="19d2", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="1bbb", MODE="0666"

Run the following commands:

sudo cp /tmp/android.rules /etc/udev/rules.d/51-android.rules
sudo chmod 644   /etc/udev/rules.d/51-android.rules
sudo chown root. /etc/udev/rules.d/51-android.rules
sudo service udev restart
sudo killall adb

Disconnect the USB cable between the phone and the computer.

Reconnect the phone.

Run adb devices to confirm that now it has permission to access the phone.

Please note that it's possible to use , USER="$LOGINNAME" instead of , MODE="0666" in the .rules file, substituting $LOGINNAME for your login name, i.e. what id -nu prints.

In some cases it can be necessary to give the udev rules file a name that sorts close to the end, such as z51-android.rules.

如日中天 2025-01-11 12:21:54

输入以下命令:

# cd to adb for sudo
cd `which adb | sed -e "s/adb//"`
adb kill-server
sudo ./adb start-server
./adb devices

This happens when you are not running adb server as root.  

Enter the following commands:

# cd to adb for sudo
cd `which adb | sed -e "s/adb//"`
adb kill-server
sudo ./adb start-server
./adb devices

This happens when you are not running adb server as root.  
此刻的回忆 2025-01-11 12:21:54

尝试了以上所有方法,但都不起作用..当我将连接从 MTP 切换到相机(PTP)时终于起作用了。

Tried all above, none worked .. finally worked when I switch connected as from MTP to Camera(PTP).

离笑几人歌 2025-01-11 12:21:54

对于这个问题有很多不好的答案,从坚持以 root 身份运行 adb(这不应该被吹捧为唯一甚至推荐的解决方案)到完全解决不相关的问题。

这是处理所有权限的最短且最通用的方法adbfastboot 设备:

echo 'ACTION=="add", SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", ENV{ID_USB_INTERFACES}=="*:ff420?:*", MODE="0666"' | sudo tee /etc/udev/rules.d/99-android.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --verbose --action=add --subsystem-match=usb

或者您可以使用我发布到此的稍长版本 要点

至于OP在他的问题中做错的具体事情 - 它在编辑.rules文件后没有重新加载udev规则。

OP 也没有透露他的手机上有哪个 Android 版本(又名 ROM)。 idVendor 值是在软件中设置的,因此它取决于 ROM。因此,他在原始规则中使用的 04E8 值仅适用于具有三星库存 ROM 的设备。但这对于这个 udev 规则来说不是问题 - 它匹配所有具有 adbfastboot 接口的设备,无论其 VendorID

There are a lot of bad answers posted to this question ranging from insisting on running adb as root (which should not be touted as the only or even recommended solution) to solving completely unrelated issues.

Here is the single shortest and most universal recipe for taking care of permissions for all adb and fastboot devices at once:

echo 'ACTION=="add", SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", ENV{ID_USB_INTERFACES}=="*:ff420?:*", MODE="0666"' | sudo tee /etc/udev/rules.d/99-android.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --verbose --action=add --subsystem-match=usb

Or you could use slightly longer version I posted to this gist.

As for the specific thing that OP did wrong in his question - it was not reloading the udev rules after editing the .rules file.

Also OP did not tell which Android build (aka ROM) he had on his phone. The idVendor value is set in software and therefore it depends on the ROM. So the value of 04E8 he used in his original rule would have worked only for devices with Samsung stock ROMs. But this is not a problem for this udev rule - it matches all devices with adb or fastboot interfaces regardless of their VendorID.

迷途知返 2025-01-11 12:21:54

在 Archlinux 中,这种情况偶尔会发生。修复:

$ sudo -s
# adb kill-server
# adb start-server

In Archlinux this can happen occasionally. The fix:

$ sudo -s
# adb kill-server
# adb start-server
心如狂蝶 2025-01-11 12:21:54

对于使用 debian 的用户,在 Ubuntu 下设置设备以创建文件“/etc/udev/rules.d/51-android.rules”的指南不起作用。我按照此处的说明进行操作。把同样的内容放在这里供参考。

以超级用户身份编辑此文件

sudo nano /lib/udev/rules.d/91-permissions.rules

找到与此类似的文本

# usbfs-like devices 
SUBSYSTEM==”usb”, ENV{DEVTYPE}==”usb_device”, \ MODE=”0664″

然后将模式更改为 0666 如下所示

# usbfs-like devices 
SUBSYSTEM==”usb”, ENV{DEVTYPE}==”usb_device”, \ MODE=”0666″

这允许 adb 工作,但是我们仍然需要设置设备以便可以识别它。我们需要以超级用户身份创建此文件,

sudo nano /lib/udev/rules.d/99-android.rules

并输入

SUBSYSTEM==”usb”, ENV{DEVTYPE}==”usb_device”, ATTRS{idVendor}==”0bb4″, MODE=”0666″

上面的行适用于 HTC,请关注 @grebulon 的帖子以获取完整列表。

保存文件,然后以超级用户身份重新启动 udev

sudo /etc/init.d/udev restart

通过 USB 连接手机,编译和运行项目时应该会检测到它。

For those using debian, the guide for setting up a device under Ubuntu to create the file "/etc/udev/rules.d/51-android.rules" does not work. I followed instructions from here. Putting down the same here for reference.

Edit this file as superuser

sudo nano /lib/udev/rules.d/91-permissions.rules

Find the text similar to this

# usbfs-like devices 
SUBSYSTEM==”usb”, ENV{DEVTYPE}==”usb_device”, \ MODE=”0664″

Then change the mode to 0666 like below

# usbfs-like devices 
SUBSYSTEM==”usb”, ENV{DEVTYPE}==”usb_device”, \ MODE=”0666″

This allows adb to work, however we still need to set up the device so it can be recognized. We need to create this file as superuser,

sudo nano /lib/udev/rules.d/99-android.rules

and enter

SUBSYSTEM==”usb”, ENV{DEVTYPE}==”usb_device”, ATTRS{idVendor}==”0bb4″, MODE=”0666″

the above line is for HTC, follow @grebulon's post for complete list.

Save the file and then restart udev as super user

sudo /etc/init.d/udev restart

Connect the phone via USB and it should be detected when you compile and run a project.

假装不在乎 2025-01-11 12:21:54

我遇到了同样的问题,解决方案如下:(顺便说一句,您不必root您的设备。)

  1. 输入“su”切换到超级用户。
  2. your-path/adb 杀死服务器。
  3. your-path/adb 启动服务器。
  4. 如果没有出现错误,您可以在root帐户中看到带有“your-path/adb devices”的设备列表。
  5. 退出超级用户。
  6. 现在您可以在您的帐户中执行“adb devices”。

享受。

I had the same problem, the solution is as fellow: (by the way, you don't have to root your device.)

  1. Type "su" to switch to super user.
  2. your-path/adb kill-server.
  3. your-path/adb start-server.
  4. If no error occurs, you can see the device list with "your-path/adb devices" in root account.
  5. Quit super user.
  6. Now you can perform "adb devices" in your account.

Enjoy.

无尽的现实 2025-01-11 12:21:54

我知道这可能有点晚了,但这里有一篇关于如何手动添加 Android ADB USB 驱动程序的非常好的文章。 在Ubuntu 14.04 LTS中手动添加Android ADB USB驱动

编辑添加链接内容

步骤

注意: 制作确保您已在 USB 调试模式下连接 Android 设备

打开终端 (CTRL + ALT + T) 并输入命令:
lsusb

现在您可能会收到类似的回复:
总线 002 设备 013:ID 283b:1024

注意:
参考此Bus 002 Device 008: ID 283b:1024
<代码>{idVendor}==”283b”
{idProduct}==”1024″

现在输入以下命令:
sudo gedit /etc/udev/rules.d/51-android.rules
这将创建 android 规则文件 (51-android.rules) 或在指定位置打开现有规则文件 (/etc/udev/rules.d)

添加新行到此文件:
SUBSYSTEM==”usb”, ATTRS{idVendor}==”283b”, ATTRS{idProduct}==”1024″, MODE=”0666″

注意 编辑 idVendor & idProduct 值与您的设备值。
保存并关闭。

现在输入以下命令:
sudo chmod a+rx /etc/udev/rules.d/51-android.rules - 授予读取/执行权限
sudo service udev restart - 重新启动 udev 服务

现在我们必须将 idVendor 添加到 adb_usb.ini。输入以下命令:
cd ~/.android
gedit adb_usb.ini

添加以下值
0x283b

这只不过是 0x(idVendor value)。因此将值替换为。尊重您的设备价值
保存并关闭文件。

现在输入以下命令:
sudo service udev restart

拔下 Android 设备并重新连接。
现在输入以下命令:
adb Kill-server
adb devices

好了!您的设备必须已列出。

复制自 在 Ubuntu 14.04 LTS 中手动添加 Android ADB USB 驱动程序

对我有用。

I know this might be a little late but here is a very good article on how to manually add Android ADB USB Driver. Manually adding Android ADB USB driver in Ubuntu 14.04 LTS

Edited to Add Link Content

Steps

Note: Make sure that you have connected your Android device in USB Debugging mode

Open terminal (CTRL + ALT + T) and enter command:
lsusb

Now you might get a similar reply to this:

Bus 002 Device 013: ID 283b:1024

Note:
With reference to this Bus 002 Device 008: ID 283b:1024
{idVendor}==”283b”
{idProduct}==”1024″

Now enter the following command:
sudo gedit /etc/udev/rules.d/51-android.rules
This creates the android rules file (51-android.rules) or open the existing one in the specified location (/etc/udev/rules.d)

Add a new line to this file:
SUBSYSTEM==”usb”, ATTRS{idVendor}==”283b”, ATTRS{idProduct}==”1024″, MODE=”0666″

Note Edit idVendor & idProduct values with your device values.
Save and close.

Now enter the following command:
sudo chmod a+rx /etc/udev/rules.d/51-android.rules - grant read/execution permission
sudo service udev restart - Restart the udev service

Now we have to add the idVendor to adb_usb.ini. Enter the following commands:
cd ~/.android
gedit adb_usb.ini

Add the following value
0x283b

This is nothing but 0x(idVendor value). So replace the value with. respect to your device value
Save and close the file.

Now enter the following command:
sudo service udev restart

Plug out the Android device and reconnect it again.
Now enter the following command:
adb kill-server
adb devices

There you go! Your device must be listed.

Copied From Manually adding Android ADB USB driver in Ubuntu 14.04 LTS

Worked for me.

感悟人生的甜 2025-01-11 12:21:54

我的 Galaxy S3 也遇到了同样的问题。
我的问题是 idVendor04E8 不正确。
要找到合适的,请将智能手机连接到计算机并在终端中运行 lsusb。它会像这样列出您的智能手机:

Bus 002 Device 010: ID 18d1:d002 Google Inc.

因此正确的 idVendor 值为 18d1/etc/udev/rules.d/51-android.rules 中的行必须是:

SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", MODE="0666", GROUP="plugdev" 

然后我运行 sudo udevadm control --reload-rules 以及所有内容成功了!

I had the same problem with my Galaxy S3.
My problem was that the idVendor value 04E8 was not the right one.
To find the right one connect your smartphone to the computer and run lsusb in the terminal. It will list your smartphone like this:

Bus 002 Device 010: ID 18d1:d002 Google Inc.

So the right idVendor value is 18d1. And the line in the /etc/udev/rules.d/51-android.rules has to be:

SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", MODE="0666", GROUP="plugdev" 

Then I run sudo udevadm control --reload-rules and everything worked!

悸初 2025-01-11 12:21:54

使用 M0Rf30/android-udev-rules GitHub 社区维护的 udev-rules

https://github.com/M0Rf30/android-udev-rules/blob/master/51-android.rules

这是迄今为止我见过的最完整的 udev-rules 列表,甚至更多比当前推荐的 sudo apt-get install android-tools-adb 官方文档,它解决了这个问题为我。

Use the M0Rf30/android-udev-rules GitHub community maintained udev-rules

https://github.com/M0Rf30/android-udev-rules/blob/master/51-android.rules

This is the most complete udev-rules list I've seen so far, even more than the currently recommended sudo apt-get install android-tools-adb on the official documentation, and it solved that problem for me.

天气好吗我好吗 2025-01-11 12:21:54
  1. 请按照 http:// developer.android.com/guide/developing/device.html(已存档链接)
  2. 0bb4 的供应商 ID 替换为/etc/udev/rules.d/51-android.rules

    中的 18d1

    或者添加另一行:

    SUBSYSTEM==“usb”,SYSFS {idVendor}==“18d1”,MODE =“0666”
    
  3. 重新启动计算机或重新启动 udev 服务。
  1. Follow the instructions at http://developer.android.com/guide/developing/device.html(Archived link)
  2. Replace the vendor id of 0bb4 with 18d1 in /etc/udev/rules.d/51-android.rules

    Or add another line that reads:

    SUBSYSTEM=="usb", SYSFS{idVendor}=="18d1", MODE="0666"
    
  3. Restart computer or just restart udev service.
酒与心事 2025-01-11 12:21:54

当你重新启动 udev 时,杀死 adb server &启动adb服务器转到android sdk安装路径&一切都在 sudo 上完成。然后运行 ​​adb devices 它将解决权限问题。

When you restart udev, kill adb server & start adb server goto android sdk installation path & do all on sudo. then run adb devices it will solve permission problem.

友谊不毕业 2025-01-11 12:21:54

我的设备是 POSITIVO,操作系统是 Ubuntu 14.04 LTS
所以,我的问题出在变量名中

,我创建了文件 /etc/udev/rules.d/51-android.rules
并输入 SUBSYSTEM=="usb", SYSFS{idVendor}=="1662", MODE="0666"

我断开了设备连接
并执行:

$ sudo udevadm control --reload-rules
$ sudo service udev restart

之后我再次以开发者模式连接Android设备并

$ adb devices

List of devices attached 
1A883XB1K   device

My device is POSITIVO and my operational system is Ubuntu 14.04 LTS
So, my problem was in variable name

I create the file /etc/udev/rules.d/51-android.rules
and put SUBSYSTEM=="usb", SYSFS{idVendor}=="1662", MODE="0666"

I disconnected device
and execute:

$ sudo udevadm control --reload-rules
$ sudo service udev restart

after this i connected the android device in developer mode again and

$ adb devices

List of devices attached 
1A883XB1K   device
赢得她心 2025-01-11 12:21:54

无需拔出

所有提供的答案均假设您能够拔出并重新连接 USB 电缆。在无法做到这一点的情况下(例如,当您在远程时),您可以执行以下操作,以基本上执行建议的 udev 规则在重新插入时执行的操作:

lsusb

找到您关心的设备,例如:

Bus 003 Device 005: ID 18d1:4ee4 Google Inc. Nexus

记下总线它所在的编号,然后执行,例如对于总线003

sudo chmod a+w /dev/bus/usb/003/*

显然这可能比您想要的更宽松(可能连接的设备不仅仅是这个),但您明白了。

Without unplugging

All the provided answers assume that you are able to unplug and reconnect the USB cable. In situations where this is not possible (e.g., when you are remote), you can do the following to essentially do what the suggested udev rules would do on re-plug:

lsusb

Find the device you care about, e.g.:

Bus 003 Device 005: ID 18d1:4ee4 Google Inc. Nexus

Take note of the bus number it is on and then execute, e.g. for bus 003:

sudo chmod a+w /dev/bus/usb/003/*

Clearly this may be more permissive than you want (there may be more devices attached than just this one), but you get the idea.

来世叙缘 2025-01-11 12:21:54

您不应该像其他答案所建议的那样以 root 身份运行 adb 服务器。相反,如果您使用 Arch Linux,请执行以下操作:

  1. 使用 Pacman 安装 android-udev 软件包
  2. 重新加载 udev 规则:

    # udevadm control --reload-rules
    
  3. 将您自己添加到 adbusers 组,然后注销并登录:

    # usermod -aG adbusers $LOGNAME
    

来源: https://wiki.archlinux.org/index.php/android#Configuring_adb< /a>

You should NOT run adb server as root as other answers are suggesting. Instead if you are using Arch Linux do the following:

  1. Install the android-udev package with Pacman
  2. Reload udev rules:

    # udevadm control --reload-rules
    
  3. Add yourself to adbusers group and then logout and login:

    # usermod -aG adbusers $LOGNAME
    

Source: https://wiki.archlinux.org/index.php/android#Configuring_adb

鸠魁 2025-01-11 12:21:54

不要遵循建议使用sudosudo adb start-server)的解决方案!这以root(管理员)身份运行adb,它不应该像那样运行! 这是一个糟糕的解决方法

以 root 身份运行的所有内容都可以在系统中执行任何操作,如果它创建或修改文件可以将其权限更改为仅由 root 使用。再说一次,不要!

正确的做法是设置您的系统以使用户拥有权限,请查看此我写了关于如何正确执行此操作的指南。

Please DO NOT follow solutions suggesting to use sudo (sudo adb start-server)! This run adb as root (administrator) and it is NOT supposed to run like that!!! It's a BAD workaround!

Everything running as root can do anything in your system, if it creates or modify a file can change its permission to be only used by root. Again, DON'T!

The right thing to do is set up your system to make the USER have the permission, check out this guide i wrote on how to do it properly.

情魔剑神 2025-01-11 12:21:54

仅适用于 Ubuntu/Debian 用户:
ubuntu要让USB调试工作需要做一些具体的事情:
此处描述:
https://developer.android.com/studio/run/device
这是提到的两个步骤。在终端中运行这两个命令:

sudo usermod -aG plugdev $LOGNAME
sudo apt-get install android-sdk-platform-tools-common

Only for Ubuntu/ Debian users:
There are some specific things to do for ubuntu to make USB debugging work:
described here:
https://developer.android.com/studio/run/device
Here are the two steps mentioned. Run this two command in terminal:

sudo usermod -aG plugdev $LOGNAME
sudo apt-get install android-sdk-platform-tools-common
南薇 2025-01-11 12:21:54

尝试使用用户的主组代替 GROUP="plugdev"

Try instead of GROUP="plugdev" use the main group of your user.

寻梦旅人 2025-01-11 12:21:54

以我在 ubuntu 12.04 LTS 上的情况为例,我必须将 HTC Incredible USB 模式从充电模式更改为媒体模式,然后该设备会显示在 adb 下。当然,这两种情况都已经进行了调试。

In my case on ubuntu 12.04 LTS, I had to change my HTC Incredible usb mode from charge to Media and then the device showed up under adb. Of course, debugging was already on in both cases.

注定孤独终老 2025-01-11 12:21:54

我遇到了同样的问题,我按照以下步骤操作:

# Clone this repository
git clone https://github.com/M0Rf30/android-udev-rules.git
cd android-udev-rules
# Copy rules file
sudo cp -v 51-android.rules /etc/udev/rules.d/51-android.rules
# OR create a sym-link to the rules file - choose this option if you'd like to update your udev rules using git.
sudo ln -sf "$PWD"/51-android.rules /etc/udev/rules.d/51-android.rules
# Change file permissions
sudo chmod a+r /etc/udev/rules.d/51-android.rules
# If adbusers group already exists remove old adbusers group
groupdel adbusers
# add the adbusers group if it's doesn't already exist
sudo mkdir -p /usr/lib/sysusers.d/ && sudo cp android-udev.conf /usr/lib/sysusers.d/
sudo systemd-sysusers # (1)
# OR on Fedora:
groupadd adbusers
# Add your user to the adbusers group
sudo usermod -a -G adbusers $(whoami)
# Restart UDEV
sudo udevadm control --reload-rules
sudo service udev restart
# OR on Fedora:
sudo systemctl restart systemd-udevd.service
# Restart the ADB server
adb kill-server
# Replug your Android device and verify that USB debugging is enabled in developer options
adb devices
# You should now see your device

上述步骤在 android-udev-rules 上进行了描述。这对我有用。

请务必确认重新插入手机后屏幕上将出现的对话框。

I had the same problem and I followed these steps:

# Clone this repository
git clone https://github.com/M0Rf30/android-udev-rules.git
cd android-udev-rules
# Copy rules file
sudo cp -v 51-android.rules /etc/udev/rules.d/51-android.rules
# OR create a sym-link to the rules file - choose this option if you'd like to update your udev rules using git.
sudo ln -sf "$PWD"/51-android.rules /etc/udev/rules.d/51-android.rules
# Change file permissions
sudo chmod a+r /etc/udev/rules.d/51-android.rules
# If adbusers group already exists remove old adbusers group
groupdel adbusers
# add the adbusers group if it's doesn't already exist
sudo mkdir -p /usr/lib/sysusers.d/ && sudo cp android-udev.conf /usr/lib/sysusers.d/
sudo systemd-sysusers # (1)
# OR on Fedora:
groupadd adbusers
# Add your user to the adbusers group
sudo usermod -a -G adbusers $(whoami)
# Restart UDEV
sudo udevadm control --reload-rules
sudo service udev restart
# OR on Fedora:
sudo systemctl restart systemd-udevd.service
# Restart the ADB server
adb kill-server
# Replug your Android device and verify that USB debugging is enabled in developer options
adb devices
# You should now see your device

The above steps are described on android-udev-rules. It worked for me.

Just be sure to confirm the dialog that will appear on your phone screen after replug it.

喜爱纠缠 2025-01-11 12:21:54
sudo usermod -aG plugdev $LOGNAME

这个命令对我有用

sudo usermod -aG plugdev $LOGNAME

This command worked for me

揽清风入怀 2025-01-11 12:21:54

当您将 USB 连接到计算机时,它会询问您是否信任计算机来调试手机上的应用程序。单击“是”解决了问题

When you connect usb to computer, it asks you if you trust the computer to debug apps on the phone. Clicking yes solved the problem

写给空气的情书 2025-01-11 12:21:54

这让我抓狂。首先也是最重要的是,这里的一些非常旧的建议可能会破坏您的 arch Linux 系统。我必须从救援 USB 启动才能撤消规则黑客行为。在我的一个案例中,我无法让我的 Android 在插入 USB 时提示授权主机,并且与其他人有相同的症状:

$ sudo adb devices
List of devices attached
89MY08NPA       no permissions; see [http://developer.android.com/tools/device.html]

是否为 root 并不重要。

进入 Android 设备的 USB 设置并确保使用 USB 设置为文件传输。由于某种原因,我的手机被设置为无数据传输,尽管我多年来一直在这款手机上进行 Android 开发。谷歌的某些更新肯定已将其切换到另一个设置。

将其设置为文件传输后,系统会提示您允许从主机进行调试并恢复正常

在此处输入图像描述

This was driving me bananas. First and foremost some of the really old suggestions here can brick your arch linux system. I had to boot from a rescue USB to undo the rules hacks. In my facepalm of a case, i couldn't get my android to prompt for authorizing the host when plugged into USB and had the same symptom as everyone else:

$ sudo adb devices
List of devices attached
89MY08NPA       no permissions; see [http://developer.android.com/tools/device.html]

being root didn't matter.

Go into your android's USB settings and make sure Use USB for is set to File Transfer. Mine was set to no data transfer for some reason even though I've been doing android dev on this phone for years. Some update from Google must have flipped it to another setting.

Once you set it to file transfer you get promted to allow debugging from the host and back to normal

enter image description here

池予 2025-01-11 12:21:54

我尝试过上述一些解决方案:

  • 重新启动adb服务器
  • 修改51-android.rules
  • 将自己添加到adbusers组

并且它工作了一次。设备要求我授权电脑,之后一切正常。

问题是当我在电脑重新启动后尝试连接设备时,问题再次出现。
为了解决这个问题,我必须手动撤销设置->开发人员选项->USB调试授权,然后设备询问我再次授权PC,这样终于成功了。

另一次,上述撤销 USB 调试授权的解决方案不起作用,为了触发设备身份验证,我必须手动禁用/启用
设置->开发人员选项->USB 调试

我使用的是 ubuntu 20.04LTS。

I had tryed some of the aforementioned solutions:

  • restart adb server
  • amend 51-android.rules
  • add myself to adbusers group

and it worked once. The device asked me to authorize the PC and afterwards, everything was working OK.

The issue was when I tried to connect the device after the PC reboot, that Again the issue was the same.
In order to vercome now this issue I had to manually revoke Settings->Developer Options->USB debugging authorizations and then the device asked me again to authorize the PC, and thus finally worked.

One other time the aforementioned solution with revoking USB debugging authorization didn't wokred, and in order to trigger authentication of the device I had to manually disable/enable the
Settings->Developer options->USB debugging

I am using ubuntu 20.04LTS.

執念 2025-01-11 12:21:54

如果您使用的是像 Ubuntu、deepin 等基于 debian 的发行版,您可以尝试运行

sudo apt-get install android-sdk-platform-tools-common

瞧,您的问题已解决

If you are on debian like Ubuntu, deepin etc based distro you can try to run

sudo apt-get install android-sdk-platform-tools-common

Voila your problem solved

何以心动 2025-01-11 12:21:54

如果所有其他解决方案均不适合您,只需拔下手机插头,关闭使用开发者选项,重新打开,然后插入手机即可。

If all other solutions don't work for you, simply unplug your phone, turn off Use developer options, turn on again then plug your phone.

高速公鹿 2025-01-11 12:21:54

我使用了 su 并且它开始工作。当我与普通用户一起使用 Jetbrains 时,我看到了这个问题,但是在 su 模式下重新启动 Jetbrains 后,我可以看到我的设备而不需要执行任何操作。

我正在使用 Ubuntu 13.04 和 Jetbrains 12.1.4

I used su and it started working. When I use Jetbrains with regular user, I see this problem but after restarting Jetbrains in su mode, I can see my device without doing anything.

I am using Ubuntu 13.04 and Jetbrains 12.1.4

想你只要分分秒秒 2025-01-11 12:21:54

您还可以尝试编辑位于 /home/username/.android/adb_usb.ini 文件。该文件包含您要连接的设备的 ID 供应商列表。您只需在新行中添加设备的 ID 供应商(每行一个 ID)。然后重新启动 adb 服务器并重新插入您的设备。

它在 Ubuntu 12.10 上对我有用。

You could also try editing adb_usb.ini file, located at /home/username/.android/. This file contains id vendor list of devices you want to connect. You just add your device's id vendor in new line (it's one id per line). Then restart adb server and replug your device.

It worked for me on Ubuntu 12.10.

想挽留 2025-01-11 12:21:54

无论如何,我做了什么来解决这个问题(在 Ubuntu 上)。

  1. 定义在什么情况下我需要运行这些命令。对于大多数 ubuntu 用户来说,有一个主文件夹(隐藏文件 .bashrc)。

    您可以在其中记录这些命令的启动。但是当你在控制台中输入bash命令时,这些命令就会被触发。

  2. 由于我有一个 shell .zshrc,所以我执行了以下操作:

    打开控制台:gedit .zshrc

当文件打开时,添加以下行:

./.add_device_permissions.sh

在之后或之前,我们需要创建此文件:.add_device_permissions.sh,在其中写入以下内容:

#!/bin/bash
# Add permissions
ADB="/home/vadimm/Android/Sdk/platform-tools/adb"
$ADB devices
$ADB kill-server
cat .permissions_redmi_note | sudo -S $ADB devices
$ADB kill-server
cat .permissions_redmi_note | sudo -S $ADB devices

此外,我们还需要在需要的位置创建 .permissions_redmi_note对我们的密码进行硬编码。

  1. 为了不添加不必要的文件.zshrc,我们可以在启动系统本身时指定路径:启动应用程序首选项

我们按“添加”并编写我们的命令:< code>/home/vadimm/.add_device_permissions.sh

  1. 您也可以尝试在命令行中使用下一个命令:
    <代码>
    ./adb 设备
    ./adb 杀死服务器
    sudo ./adb 设备
    ./adb 杀死服务器
    ./adb 设备

Anyway, what I did to solve this problem(on Ubuntu).

  1. Defined in what cases I need to run these commands. For most ubuntu users there is a home folder (hidden file .bashrc).

    In which you can record the launch of these commands. But these commands will be triggered when you enter the bash command in the console.

  2. Since I have a shell .zshrc then I did the following:

    open console: gedit .zshrc

When the file opens, add the following line:

./.add_device_permissions.sh

After or before, we need to create this file: .add_device_permissions.sh in which we write the following:

#!/bin/bash
# Add permissions
ADB="/home/vadimm/Android/Sdk/platform-tools/adb"
$ADB devices
$ADB kill-server
cat .permissions_redmi_note | sudo -S $ADB devices
$ADB kill-server
cat .permissions_redmi_note | sudo -S $ADB devices

Also we need create .permissions_redmi_note where we need to hardcode our password.

  1. Not to add to the file .zshrc unnecessary we can specify the path when starting the system itself: Startup Applications Preferences

Where we press on "Add" and write our command: /home/vadimm/.add_device_permissions.sh

  1. Also u can tried use in command line next commands:

    ./adb devices
    ./adb kill-server
    sudo ./adb devices
    ./adb kill-server
    ./adb devices
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文