我使用的是三星 Galaxy Nexus 手机(Android 4.0 平台)。
我正在 Ubuntu Linux 操作系统上开发 Android 应用程序。我想直接在三星手机设备上运行我的应用程序,因此我执行了以下设置步骤:
-
在我的项目 AndroidManifest.xml
文件中,添加 android:debuggable="true "
到我的项目 AndroidManifest.xml
文件中的
元素
在设备上的设置> 中启用安全性 未知来源
-
在设备上的设置>中开发者选项已启用USB调试
-
在我的计算机上,使用以下内容创建了/etc/udev/rules.d/51-android.rules
文件内容:
SUBSYSTEM==“usb”,ATTR {idVendor}==“04E8”,MODE =“0666”,GROUP =“plugdev”
-
在我的计算机上,运行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:
-
in my project AndroidManifest.xml
file, added android:debuggable="true"
to the <application>
element
-
On the device, in the Settings > Security enabled Unknown sources
-
On the device, in the Settings > Developer options enabled USB debugging
-
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"
-
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?
发布评论
评论(30)
对我有用的是杀死并再次启动 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 thensudo adb start-server
. Then it will detect nearly every device out of the box.直到我终于在这里找到答案之前,一切都对我不起作用:
http://ptspts .blogspot.co.il/2011/10/how-to-fix-adb-no-permissions-error-on.html
我将文本复制到此处,以防它在 未来。
创建一个名为 /tmp/android.rules 的文件,其中包含以下内容(十六进制供应商编号取自供应商列表页面):
运行以下命令:
断开手机和计算机之间的 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):
Run the following commands:
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. whatid -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
.输入以下命令:
Enter the following commands:
尝试了以上所有方法,但都不起作用..当我将连接从 MTP 切换到相机(PTP)时终于起作用了。
Tried all above, none worked .. finally worked when I switch connected as from MTP to Camera(PTP).
对于这个问题有很多不好的答案,从坚持以 root 身份运行 adb(这不应该被吹捧为唯一甚至推荐的解决方案)到完全解决不相关的问题。
这是处理所有权限的最短且最通用的方法
adb
和fastboot
设备:或者您可以使用我发布到此的稍长版本 要点。
至于OP在他的问题中做错的具体事情 - 它在编辑
.rules
文件后没有重新加载udev
规则。OP 也没有透露他的手机上有哪个 Android 版本(又名 ROM)。
idVendor
值是在软件中设置的,因此它取决于 ROM。因此,他在原始规则中使用的04E8
值仅适用于具有三星库存 ROM 的设备。但这对于这个udev
规则来说不是问题 - 它匹配所有具有adb
或fastboot
接口的设备,无论其 VendorID。There are a lot of bad answers posted to this question ranging from insisting on running
adb
asroot
(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
andfastboot
devices at once: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 of04E8
he used in his original rule would have worked only for devices with Samsung stock ROMs. But this is not a problem for thisudev
rule - it matches all devices withadb
orfastboot
interfaces regardless of their VendorID.在 Archlinux 中,这种情况偶尔会发生。修复:
In Archlinux this can happen occasionally. The fix:
对于使用 debian 的用户,在 Ubuntu 下设置设备以创建文件“/etc/udev/rules.d/51-android.rules”的指南不起作用。我按照此处的说明进行操作。把同样的内容放在这里供参考。
以超级用户身份编辑此文件
找到与此类似的文本
然后将模式更改为 0666 如下所示
这允许 adb 工作,但是我们仍然需要设置设备以便可以识别它。我们需要以超级用户身份创建此文件,
并输入
上面的行适用于 HTC,请关注 @grebulon 的帖子以获取完整列表。
保存文件,然后以超级用户身份重新启动 udev
通过 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
Find the text similar to this
Then change the mode to 0666 like below
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,
and enter
the above line is for HTC, follow @grebulon's post for complete list.
Save the file and then restart udev as super user
Connect the phone via USB and it should be detected when you compile and run a project.
我遇到了同样的问题,解决方案如下:(顺便说一句,您不必root您的设备。)
享受。
I had the same problem, the solution is as fellow: (by the way, you don't have to root your device.)
Enjoy.
我知道这可能有点晚了,但这里有一篇关于如何手动添加 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 permissionsudo service udev restart
- Restart theudev
serviceNow we have to add the
idVendor
toadb_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 valueSave 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.
我的 Galaxy S3 也遇到了同样的问题。
我的问题是
idVendor
值04E8
不正确。要找到合适的,请将智能手机连接到计算机并在终端中运行
lsusb
。它会像这样列出您的智能手机:因此正确的
idVendor
值为18d1
。/etc/udev/rules.d/51-android.rules
中的行必须是:然后我运行
sudo udevadm control --reload-rules
以及所有内容成功了!I had the same problem with my Galaxy S3.
My problem was that the
idVendor
value04E8
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:So the right
idVendor
value is18d1
. And the line in the/etc/udev/rules.d/51-android.rules
has to be:Then I run
sudo udevadm control --reload-rules
and everything worked!使用
M0Rf30/android-udev-rules
GitHub 社区维护的 udev-ruleshttps://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-ruleshttps://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.将
0bb4
的供应商 ID 替换为/etc/udev/rules.d/51-android.rules
中的
18d1
或者添加另一行:
Replace the vendor id of
0bb4
with18d1
in/etc/udev/rules.d/51-android.rules
Or add another line that reads:
当你重新启动 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.
我的设备是 POSITIVO,操作系统是
Ubuntu 14.04 LTS
所以,我的问题出在变量名中
,我创建了文件 /etc/udev/rules.d/51-android.rules
并输入
SUBSYSTEM=="usb", SYSFS{idVendor}=="1662", MODE="0666"
我断开了设备连接
并执行:
之后我再次以开发者模式连接Android设备并
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:
after this i connected the android device in developer mode again and
无需拔出
所有提供的答案均假设您能够拔出并重新连接 USB 电缆。在无法做到这一点的情况下(例如,当您在远程时),您可以执行以下操作,以基本上执行建议的 udev 规则在重新插入时执行的操作:
找到您关心的设备,例如:
记下总线它所在的编号,然后执行,例如对于总线
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:
Find the device you care about, e.g.:
Take note of the bus number it is on and then execute, e.g. for bus
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.
您不应该像其他答案所建议的那样以 root 身份运行
adb
服务器。相反,如果您使用 Arch Linux,请执行以下操作:android-udev
软件包重新加载 udev 规则:
将您自己添加到
adbusers
组,然后注销并登录:来源: 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:android-udev
package with PacmanReload udev rules:
Add yourself to
adbusers
group and then logout and login:Source: https://wiki.archlinux.org/index.php/android#Configuring_adb
请不要遵循建议使用
sudo
(sudo 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.
仅适用于 Ubuntu/Debian 用户:
ubuntu要让USB调试工作需要做一些具体的事情:
此处描述:
https://developer.android.com/studio/run/device
这是提到的两个步骤。在终端中运行这两个命令:
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:
尝试使用用户的主组代替
GROUP="plugdev"
。Try instead of
GROUP="plugdev"
use the main group of your user.以我在 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.
我遇到了同样的问题,我按照以下步骤操作:
上述步骤在 android-udev-rules 上进行了描述。这对我有用。
请务必确认重新插入手机后屏幕上将出现的对话框。
I had the same problem and I followed these steps:
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.
这个命令对我有用
This command worked for me
当您将 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
这让我抓狂。首先也是最重要的是,这里的一些非常旧的建议可能会破坏您的 arch Linux 系统。我必须从救援 USB 启动才能撤消规则黑客行为。在我的一个案例中,我无法让我的 Android 在插入 USB 时提示授权主机,并且与其他人有相同的症状:
是否为 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:
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
我尝试过上述一些解决方案:
并且它工作了一次。设备要求我授权电脑,之后一切正常。
问题是当我在电脑重新启动后尝试连接设备时,问题再次出现。
为了解决这个问题,我必须手动撤销
设置
->开发人员选项
->USB调试授权
,然后设备询问我再次授权PC,这样终于成功了。另一次,上述撤销 USB 调试授权的解决方案不起作用,为了触发设备身份验证,我必须手动禁用/启用
设置
->开发人员选项
->USB 调试
我使用的是 ubuntu 20.04LTS。
I had tryed some of the aforementioned solutions:
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.
如果您使用的是像 Ubuntu、deepin 等基于 debian 的发行版,您可以尝试运行
瞧,您的问题已解决
If you are on debian like Ubuntu, deepin etc based distro you can try to run
Voila your problem solved
如果所有其他解决方案均不适合您,只需拔下手机插头,关闭
使用开发者选项
,重新打开,然后插入手机即可。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.我使用了 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
您还可以尝试编辑位于 /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.
无论如何,我做了什么来解决这个问题(在 Ubuntu 上)。
定义在什么情况下我需要运行这些命令。对于大多数 ubuntu 用户来说,有一个主文件夹(隐藏文件
.bashrc
)。您可以在其中记录这些命令的启动。但是当你在控制台中输入
bash
命令时,这些命令就会被触发。由于我有一个 shell .zshrc,所以我执行了以下操作:
打开控制台:
gedit .zshrc
当文件打开时,添加以下行:
在之后或之前,我们需要创建此文件:
.add_device_permissions.sh
,在其中写入以下内容:此外,我们还需要在需要的位置创建 .permissions_redmi_note对我们的密码进行硬编码。
.zshrc
,我们可以在启动系统本身时指定路径:启动应用程序首选项
我们按“添加”并编写我们的命令:< code>/home/vadimm/.add_device_permissions.sh
<代码>
./adb 设备
./adb 杀死服务器
sudo ./adb 设备
./adb 杀死服务器
./adb 设备
Anyway, what I did to solve this problem(on Ubuntu).
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.Since I have a shell .zshrc then I did the following:
open console:
gedit .zshrc
When the file opens, add the following line:
After or before, we need to create this file:
.add_device_permissions.sh
in which we write the following:Also we need create .permissions_redmi_note where we need to hardcode our password.
.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
./adb devices
./adb kill-server
sudo ./adb devices
./adb kill-server
./adb devices