One solution is to disable MTP on the device:
Settings --> Storage --> Top Left Option (Computer USB Connection) tap--> uncheck "choose MTP"
However this may not be possible if you wish to automate the process.
A workaround solution for Linux is to prevent MTP probes from happening (this allows the Android device to keep appearing as a composite device with both an MTP and ADB interface). The simplest way to do this on Ubuntu is sudo apt get remove libmtp-common libmtp-runtime libmtp9
, then reboot. You will no longer be able to use MTP on that computer.
You can use lsusb -v
to verify that the MTP/ADB issue is fixed; If you see multiple bInterfaceDescriptor
s under your device, and one has a bInterfaceSubClass
of 66
(0x42), but you still see no entries in adb devices
, you have a different problem.