📌  相关文章
📜  adb:设备权限不足:缺少 udev 规则?用户在 plugdev 组中 (1)

📅  最后修改于: 2023-12-03 14:59:11.356000             🧑  作者: Mango

ADB: Device Permission Denied: Missing udev Rules? User in plugdev group.

When working with Android devices and the adb (Android Debug Bridge) tool, you may encounter the following error: "Device permission denied: missing udev rules? User in plugdev group." This error indicates that there is a problem with the permissions for the device you are trying to connect to.

What is udev?

Udev is a Linux subsystem that creates and manages device nodes in the /dev directory. When a device is connected to your system, udev is responsible for detecting it and creating the appropriate device node so that it can be accessed by applications and tools like adb.

How to fix the error

The error message suggests that the user trying to use adb is not a member of the plugdev group, which is required for access to USB devices. To fix the issue, add the user to the plugdev group by running the following command:

sudo usermod -aG plugdev <username>

Replace with the username of the user you want to add to the group. After running this command, log out and log back in for the changes to take effect.

If the error persists, you may need to create a udev rule for your device. This rule tells udev to set the correct permissions for the device node when it is created. To create a udev rule, create a file in /etc/udev/rules.d/ with a name ending in .rules, such as android.rules. In this file, add the following line:

SUBSYSTEM=="usb", ATTR{idVendor}=="<vendor_id>", MODE="0666", GROUP="plugdev"

Replace <vendor_id> with the vendor ID of your device. You can find this ID by running lsusb in a terminal and looking for the line that corresponds to your device. Once you have added the udev rule, unplug and reconnect your device for the changes to take effect.

Conclusion

By adding the user to the plugdev group and creating a udev rule if necessary, you can resolve the "Device permission denied: missing udev rules? User in plugdev group" error and successfully use adb to interact with your Android device.