Search code examples
androidlinuxadb

Is there any way of making ADB not crash when file transfer is not enabled on phone connected through USB?


for some time whenever I attach an Android device and is not set up to "File transfer" option ADB crashes.
Going through ADB startup logs I find the following error: connection terminated: failed to open device: Access denied (insufficient permissions)

This is the output of adb --version:

Android Debug Bridge version 1.0.41
Version 35.0.2-12147458
Installed as /home/user/Android/Sdk/platform-tools/adb
Running on Linux 6.11.0-108013-tuxedo (x86_64)

Running on TuxedoOS 24.04

Anything I can do from stopping the crashes?


Solution

  • The issue you're experiencing with ADB crashing when the phone is not set to "File transfer" mode is likely due to insufficient permissions. Here are a few steps you can take to resolve this issue:

    1. Update ADB: Ensure you have the latest version of ADB.

    2. Udev Rules: On Linux, you may need to set up udev rules to grant the necessary permissions to ADB. Create a file named 51-android.rules in the /etc/udev/rules.d/ directory with the following content:

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

      Replace 18d1 with the vendor ID of your device. You can find the vendor ID by running lsusb with your device connected.

    3. Restart Udev: After creating the udev rules file, restart the udev service:

      sudo udevadm control --reload-rules
      sudo service udev restart
      
    4. Add User to Plugdev Group: Ensure your user is part of the plugdev group:

      sudo usermod -aG plugdev $USER
      
    5. Reboot: Reboot your system to apply the changes.

    6. Check Permissions: Ensure that the ADB server has the necessary permissions to access the device. You can restart the ADB server with elevated permissions:

      sudo adb kill-server
      sudo adb start-server
      

    By following these steps, you should be able to prevent ADB from crashing when the phone is not set to "File transfer" mode.