Saturday, February 21, 2015

Dealing with Android MTP devices in Linux

A couple of frustrating errors you might see when trying to exchange files with your Android phone:

"-1: Unspecified error."


My personal favorite when copying a file to or from the device, the "-6: Not Supported."



Try using jmtpfs.  From Ubuntu/Mint, it is a simple install with "sudo apt-get install jmtpfs".

It isn't perfect, but better than the "native" MTP transfer provided by libmtp, which is clearly broken in Linux and has been for some time. There is no other explanation, as there are several other MTP solutions which according to the Arch Wiki, "...aim at better functionality and performance over libmtp."

Using jmtpfs is pretty simple, just create a directory to use as a mount point, then use jmtpfs to mount your device at that directory.  You can then use the command line or a file manager to navigate to that folder and copy files to/from it.

Other usage patterns can be found in the jmtpfs readme.

I still got an error while trying to overwrite an existing file, so as I said this solution isn't perfect, but it works better than libmtp with my Moto G.  Here is an example of mounting the device to a directory called "mnt":

Removed demonstration gist, but you can view it here if you are interested.

Update 28-Feb-2015:
After more use, I found that jmtpfs is useful for one or two files, but if you need to transfer, say, all of your phone data to your computer as a backup, it was not reliable.  I found the go-mtpfs solution to work very well.  Initially I was not very excited about this solution because it required installing another language (Google's "Go") and some usb libraries, BUT -- the author has kindly provided (or linked to) compiled binaries, which eliminate these worries!

All you need to do is download the binary for your environment.  In my case I chose go-mtpfs.x86_64.

Make the binary executable and test it to see if it runs:


Then plug in your phone and mount it:



That's it!  You should see your phone mounted at ~/phone.  Now you can use Nautilus or whatever to copy and move files.  The author warns that renaming between directories isn't implemented, and you may not see updates to the filesystem done by the phone.  These concerns are minor for what I'm after.

To unmount the phone, do:


Works very reliably.  I just transferred 2GB of data without an issue.


Saturday, February 7, 2015

Google Play Music App Unresponsive or Slow

I reverted my Moto G (2013) to the stock ROM and rooted it, but since I did this, I have been having frustrating problems with Play Music that make it unusable:
  • Select a song and nothing happens 
  • Press play and nothing happens 
  • After several minutes a song may play, but pressing pause won't stop it

Killing the running Music app will obviously get a playing song to stop, but the base problem is still there -- the entire app is basically useless.

I tried wiping data for the app, wiping the app's cache, rebooting the phone... nothing helped, and Play Music remained a slug.

SOLUTION:
Today I completely uninstalled the app using Titanium Backup.  Since Google Play Music is a system app, you will need root privileges to do this.

After completely uninstalling the system version of the app from the phone, I re-installed it through the Play Store, and so far it behaves as I expect it to.  Something must be incompatible between the factory version and the "update", however that mechanism (system app vs. "updated" version from market) works in Android.

Update 28-Feb-2015:
This started happening again.  I removed Play Music and re-installed it, and it started behaving again.  It might be due to having a lot of cached music on the phone, I don't know, but it is annoying the hell out of me and I am going to install CyanogenMod again tonight to see if it is a problem with the stock ROM.