Linux 设置用于开发的设备(???????????? 无权限)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9210152/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 04:28:57  来源:igfitidea点击:

set up device for development (???????????? no permissions)

androidlinuxubuntuadbfastboot

提问by Leem.fin

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

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

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:

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

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

  2. On the device, in the Settings > Securityenabled Unknown sources

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

  4. On my computer, created the /etc/udev/rules.d/51-android.rulesfile 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.rulescommand

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

  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命令

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

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

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

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

由于我没有看到我的设备,而只有???????????? no permissions,我然后运行以下命令:

 adb kill-server
 adb start-server
 adb devices

But I still got:

但我仍然得到:

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

Why? What am I missing?

为什么?我错过了什么?

采纳答案by WarrenFaith

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

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

回答by Yury

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

尝试而不是GROUP="plugdev"使用您的用户的主要组。

回答by Chinthaka Senanayaka

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.

当您重新启动 udev 时,杀死 adb 服务器并启动 adb 服务器转到 android sdk 安装路径并在 sudo 上执行所有操作。然后运行 ​​adb devices 它将解决权限问题。

回答by iancrowther

Enter the following commands:

输入以下命令:

adb kill-serversudo ./adb start-serveradb devices

adb kill-serversudo ./adb start-serveradb devices

The issue is your not running adb server as root.

问题是您没有以 root 身份运行 adb 服务器。

回答by grebulon

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

在我终于在这里找到答案之前,没有什么对我有用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):

创建一个名为 /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"

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.

断开手机和计算机之间的 USB 数据线。

Reconnect the phone.

重新连接手机。

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

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

Please note that it's possible to use , USER="$LOGINNAME"instead of , MODE="0666"in the .rulesfile, substituting $LOGINNAMEfor your login name, i.e. what id -nuprints.

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

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.

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

回答by Jeffrey Yang

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

Enjoy.

享受。

回答by krishnendu

  1. Follow the instructions at http://developer.android.com/guide/developing/device.html(Archived link)
  2. Replace the vendor id of 0bb4with 18d1in /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.
  1. 按照http://developer.android.com/guide/developing/device.html (存档链接)上的说明进行操作
  2. 0bb418d1in替换供应商 ID/etc/udev/rules.d/51-android.rules

    或者添加另一行,内容如下:

    SUBSYSTEM=="usb", SYSFS{idVendor}=="18d1", MODE="0666"
    
  3. 重新启动计算机或只是重新启动 udev 服务。

回答by jaga

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.

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

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

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

# 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,

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

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.

上面这行是针对 HTC 的,请关注@grebulon 的帖子以获取完整列表。

Save the file and then restart udev as super user

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

sudo /etc/init.d/udev restart

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

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

回答by Alan

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.

就我在 ubuntu 12.04 LTS 上的情况而言,我不得不将我的 HTC Incredible USB 模式从充电更改为媒体,然后设备出现在 adb 下。当然,在这两种情况下都已经进行了调试。

回答by Deepti Kohli

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.

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

I am using Ubuntu 13.04 and Jetbrains 12.1.4

我使用的是 Ubuntu 13.04 和 Jetbrains 12.1.4