13

(Note: This question originally expressed two problems. After creating the bounty, I figured some things out, so I've narrowed it down to just one problem.)

I have just made a fresh install of Ubuntu 14.04.

When I plug in my Android phone by USB, I can access the files on the phone, though not smoothly. Image and sound files won't open unless I copy them to the computer first. Banshee crashes if the Android is connected.

This is the error if I try to open an image file:

enter image description here

"Failed to open input stream for file"

Why am I getting this error and how do I get my Android to connect without problems?

Note, I have tried switching from MTP to PTP mode, and when I do, I can't seem to acess files on the phone at all. I have installed mtp-tools. I can connect by USB mass storage, and then I can view image files and use Banshee. The downside there is that it takes half a dozen screens and selections on the Android device to enable USB mass storage mode each time I connect, and I'm looking for plug and play functionality.

Also note, I am agnostic about solutions in that I don't care if it means using MTP, PTP, or USB mass storage. I want to be able to use my Android device seemlessly, just plug it in and use, and I'm not bothered about how that happens.

The Android device is a Samsung Galaxy S2, running Android 4.1.2.

Questioner
  • 6,839
  • switch to mass storage mode and then connect your phone. – Avinash Raj Apr 18 '14 at 09:34
  • @AvinashRaj, it takes about 5 steps to get to mass storage mode. I hope it's not the case that the only solution is to go through that every time I connect my phone. – Questioner Apr 18 '14 at 09:36
  • The problem is mtp devices doesn't support basic file I/O. Take a look at this answer from another question. –  May 05 '14 at 17:55
  • What android device do you have? – Seth May 05 '14 at 19:11
  • @Seth, added the device information to the question. – Questioner May 06 '14 at 10:45
  • This is so frustrating! I have a Galaxy S4, and am running into this issue on Ubuntu 14.04. MTP mode is the only way to get access to .mp4 videos, ptp mode doesn't share them. I tried connecting my phone to my windows 8.1 laptop, and it fails on windows! So it seems to be unreliable, and nothing to do with Ubuntu. My workaround, create a cifs share on my Ubuntu box, then use an SMB client on andriod to copy to the share. So slooow! – Nick Jun 14 '15 at 18:54
  • I just found this answer: http://askubuntu.com/questions/473151/how-do-i-access-files-on-an-mtp-device?s=1|0.4528 Copy the files first, then they are all readable. – Nick Jun 14 '15 at 19:43

7 Answers7

6

The error which was clearly shown is, Unable to mount MTP device. So your system fails to mount(open) this mtp device. Installing mtp-tools package will solve this error and makes your mtp device to get connected.

sudo apt-get install mtp-tools
Mark Kirby
  • 18,529
  • 19
  • 78
  • 114
Avinash Raj
  • 78,556
  • 2
    Connect your phone in USB 3.0 port not in 2.0 – Avinash Raj Apr 20 '14 at 01:18
  • The one with bluetongue=USB 3.0. Make sure that you have disabled USB tethering option on your phone. – Avinash Raj Apr 20 '14 at 01:27
  • 2
    According to lsusb, all my USB ports are USB 2.0. Also, USB tethering is not enabled. I appreciate your help, and you may be right that this error is partly to do with my computer's USB 2.0 connection, but I find it hard to believe there is no way to solve this error without getting a USB 3.0 port. – Questioner Apr 20 '14 at 01:31
  • 1
    @AvinashRaj wow wow wow! Connecting to usb 3.0 solved my problem (of file transfering failures with random kind) after trying a lotof solutions, thank you! Can you explain please, why usb 3.0 connection is significant? – ASten Mar 18 '17 at 22:08
  • connecting to the other USB port (probably USB 3.0) did the trick for me too, thanks! – gevra Feb 23 '24 at 20:11
2

Resolved this issue by upgrading to Android 4.4. Now, when I plug in the device, I get an "Android" device in Nautilus, which has two separate drives available, my internal and external SD card. There are no interface actions on the phone needed to connect the device. I actually can't tell if it's connecting using MTP or USB mass storage or what, but so long as it's working, I'm not too concerned about it.

Media files don't have preview icons, but can be opened and viewed without any errors.

Questioner
  • 6,839
2

On my galaxy s3 (android 4.4), I changed my settings from Media Device (MTP) to Camera (PTP) and I was able to view my Pictures and others files just fine.

1

You'll be happy to know the previous set of USB utilities is still there to use. This is a work around rather than a permanent fix. RC

  1. On your android phone, go to Application->Settings
  2. In there, go to Wireless and Network and select USB Utilities
  3. Click on Connect Storage to PC, before you connect a USB cable
  4. A message should pop up: Connect USB cable to use mass storage
  5. Now connect the USB cable to computer
  6. The green android robot should be displayed with an option button for "Connect USB storage;" click on that.
  7. The green robot turns orange and now you can access the files on the internal storage and SD card of your phone.

source: http://catlingmindswipe.blogspot.com/2012/05/how-to-connect-android-samsung-galaxy.html

My tests indicate that installing PCManFM from Software Center will also allow you to access your files on the device in the way it worked in years gone by.

Andy
  • 616
Elder Geek
  • 36,023
  • 25
  • 98
  • 183
  • 1
    Thank you for this answer. As mentioned in the question, I am aware that this option existed. However, I am looking to have plug-and-play functionality. Having to go through that set of options every time is inconvenient and prone to error. – Questioner May 08 '14 at 01:39
  • @ Dave M G I'm sorry that your Samsung Galaxy S2 requires more steps to connect that you like. Perhaps the community can correct me If I'm wrong, but I believe changes to your Samsung firmware and/or Android 4.1.2 are a bit beyond the scope of this forum. – Elder Geek May 08 '14 at 13:40
  • The issue is that the kind of connectivity I am speaking about used to exist. A few years ago, I could plug in my Android, and it would just show up as an external drive, and that was that. However, my understanding is that Google decided to make their Android devices MTP by default, but that the Ubuntu support for MTP has been very patchy. I believe my Android device is doing the standard of what Android devices do, but that Ubuntu's support for it is weak. So, I think that puts the onus on Ubuntu. – Questioner May 08 '14 at 13:45
  • I have the exact same results with my android device under 14.04 as I have under 12.04. Granted my device is running an older version of the Android system than yours (2.37) and I am unable to reproduce with either that device nor a newer device running 4.3.2 I will install mtp-tools and see if I can reproduce and if so see if uninstalling same solves the problem and edit my answer accordingly. – Elder Geek May 08 '14 at 14:31
  • My results with mpt-tools are worse than yours (No Devices detected thus far) – Elder Geek May 08 '14 at 15:56
  • @DaveMG The type of functionality you are referring to "a few years ago", I'm assuming this was a different device with a different version of the Android system. Is this correct? – Elder Geek May 08 '14 at 18:33
  • Awarded the bounty here because even though I feel I haven't really reached a satisfying conclusion, I do appreciate how much you've tried to help. – Questioner May 09 '14 at 05:35
  • The functionality I am referring to was just a little over two years, and around when I first got it. My memory is that it first operated by default as a USB mass storage device. The Android version did get upgraded since then (I think I started with 4.0), and of course Ubuntu also has moved on. I can't say exactly where along the way things started to go awry. For a while I went away from Ubuntu to Linux Mint, and now I'm back again. – Questioner May 09 '14 at 06:38
  • I'll continue to look into this and see if I can actually earn the bounty you so graciously awarded me. I'm working through the issues I have with testing here: http://askubuntu.com/questions/463017/problems-detecting-android-tablet-iview-788tpc-with-mtp-tools Hopefully I or one of the other wonderful people here will discover something related – Elder Geek May 09 '14 at 15:43
0

Having run into this problem many times, my feeling is, that it appears to happen more often with Samsung phones than with Huawei phones. I have not tested with others.

The problem is by my analysis, that Samsung allows exactly one MTP session after an USB cable has been connected and the user authorized file transfer. However, Ubuntu (and Kubuntu as well) apparently close and re-open the MTP session after already a few seconds of inactivity, or they try to use parallel MTP sessions (like one for directory listings and one for actual file transfer etc.). But the new MTP session is not authorized and boom, there is the error message, and the Samsung phone will even close the already authorized MTP session.

The best workaround is to use mtp-tools to permanently mount the android device. For reference see basically: https://wiki.ubuntuusers.de/MTP/

So I typed in a terminal window:

sudo apt-get install mtp-tools
sudo apt-get install jmtpfs
mkdir ~/samsung

(This needs only to be done once. On older Ubuntu versions, install package mtpfs instead of jmtpfs)

Then each time you want to connect the phone, connect the USB cable, unlock the phone, then on the phone bring up the message list by sliding down from the top, and look for the entry "Android system - USB for nnn". Tap that item, so that an overlay window opens, that lets you set the USB mode. Explicitely select "file transfer". If file transfer is already selected, select something else instead, then bring the window up again, and select "file transfer" a second time. Yes, having to use this window twice smells very much like a Samsung bug.

Sometimes, especially after failed mount attempts, the phone also brings up an "allow phone data access" dialog, that only allows "yes" and "no" as answers. Using that dialog works, too.

After all this preparation, just do:

jmtpfs ~/samsung

And voilá, your long sought after files appear in your ~/samsung directory, and more important, stay there until you disconnect the USB cable or power off either the smartphone or the computer. It doesn't even hurt, if the phone locks its display or turns off the display, as long, as it is not completely off. But don't try to click on the icon for the phone in the Ubuntu/Kubuntu file viewer. That will attempt to open a second MTP session and could actually kill the first MTP session, too. Instead, access the aforementioned ~/samsung directory.

To unmount the phone later, just type:

fusermount -u ~/samsung
0

This may work with 4.1.2 as well.... cannot confirm

Storage [Tip] Re-enabling Mass Storage Mode Android 4.2.2 Just wanted to share some tips to those who wanted to re-enable the Mass Storage Mode on their Android 4.2.2

  1. Connect your phone to a computer (The device will be connected in MTP mode as default)
  2. Reboot your phone while connected to the computer
  3. Wait until you see the USB icon on your Notification Bar
  4. You will now have an option to select Mass Storage henceforth

source: http://forum.xda-developers.com/showthread.php?t=2350542

Elder Geek
  • 36,023
  • 25
  • 98
  • 183
  • Thank you for this suggestion. Just tried it, and unfortunately, the only options it shows are MTP and PTP. It may be a 4.2.2 only option. – Questioner May 08 '14 at 15:35
  • 1
    @DaveMG Well, it was a long shot. Still might help someone. Hopefully something better suited will arrive. – Elder Geek May 08 '14 at 15:54
  • @DaveMG Here's another interesting thread which may be of some use: http://ubuntuforums.org/showthread.php?t=2194853 – Elder Geek May 08 '14 at 16:03
  • Install PCManFM File manager. This works seemlessly for me under 14.04. I discovered it worked under Lubuntu which uses PCMan File Manager by default so, tested and confirmed under Ubuntu 14.10 – Elder Geek May 09 '14 at 16:56
  • 1
    Won't PCManFM File Manager replace my window interface entirely? It's not that I'm against using a different interface if it works better, it's just that seems like a large scale change with possible side effects and reprocussions. I'd have to be sure about the degree of upheaval it would cause before using it just to solve this one issue. – Questioner May 09 '14 at 17:30
  • It didn't change anything regarding my interface. If anything goes awry it can simply be uninstalled. I'm not certain this will work for your device, It did work for mine. My default file manager (nautilus) remains unchanged and still works as expected.. – Elder Geek May 09 '14 at 17:43
0

I have got a Galaxy S6, and I saw the same issue in Ubuntu 15.10 when accessing the files on the device (Failed to open input stream for image).

However, I was able to copy the files to my laptop and viewing them there, without altering any settings on phone/computer.

raggyp
  • 101