Tuesday, November 13, 2012

Sync folders between Android and Ubuntu 12.04

One of the things that I find not so straightforward for Android devices is syncronizing music and other files. I have been trying with Rhythmbox and Banshee but both either crash and/or don't copy all songs.This is how I managed to sync files from my Galaxy Nexus (GSM). This is a tethered sync over USB. There will be another post showing how to do it over WiFi with Samba Share. Try at your own risk. 
As a precaution you may want to rename your device's Music folder and recreate it. In case you do something horribly wrong and you are syncing TO the computer and delete your phone's music/pics/whatever... files.

The programs used are:
  • Conduit for Ubuntu
sudo mkdir /media/gnex
sudo apt-get install conduit  
sudo apt-get install mtp-tools mtpfs 
sudo adduser YOURUSERNAME fuse
sudo mtpfs -o allow_other /media/gnex
sudo gedit /etc/udev/rules.d/51-android.rules
Paste this in that file (note *1)
SUBSYSTEM=="usb", ATTR{idVendor}=="043", ATTR{idProduct}=="685c", MODE="0666"
Create system commands to save you time in mounting.
  • sudo gedit ~/.bashrc 
Paste at the end of the file (all single quotes): 
alias android-connect='mtpfs -o allow_other /media/gnex' 
alias android-disconnect='fusermount -u /media/gnex'
Note *1:
Use mtp-detect | grep idVendor and mtp-detect | grep idProduct to get the correct values for your device.

Installation is finished. To test your setup run android-connect and you should see you should see the following in Nautilus (file browser). To unmount your device run android-disconnect .

 Open up Conduit. Drag two folder providers from the left panel. Right click on the one on the left and set the first folder to sync. Repeat the above for the second "folder" on the right. You may add an option to make it two-way so that new files on the phone are added to your computer.

Now that your gnex folder is browsable setup your sync source and destination.

When you are ready to sync right-click on the arrow(s) and click Syncronize Group. Wait and verify with a file manager on your Android device.

 Files are displayed on device App.